* src/gramps_main.py (__init__): Catch "ErrorSchemaInvalid" exception

* src/Errors.py (GConfSchemaError): Add new exception.
* src/const.py.in: Remove exception string "ErrorSchemaInvalid"
(replaced by new class).
* src/GrampsGconfKeys.py (get_bool,get_int,get_string): Raise exception.


svn: r4204
This commit is contained in:
Alex Roitman
2005-03-17 20:33:36 +00:00
parent 42353719e3
commit dac485ee26
4 changed files with 19 additions and 12 deletions

View File

@@ -81,3 +81,12 @@ class HandleError(Exception):
def __str__(self):
return self.value
class GConfSchemaError(Exception):
"""Error used to report the absence of expected GConf schema."""
def __init__(self,value):
Exception.__init__(self)
self.value = value
def __str__(self):
return self.value

View File

@@ -38,7 +38,7 @@ except ImportError:
import gobject
import os
from const import ErrorSchemaInvalid
import Errors
client = gconf.client_get_default()
client.add_dir("/apps/gramps",gconf.CLIENT_PRELOAD_NONE)
@@ -349,7 +349,7 @@ def get_bool(key):
else:
val = client.get_default_from_schema(key)
if val == None:
raise ErrorSchemaInvalid, "No default value for key "+key
raise Errors.GConfSchemaError("No default value for key "+key)
return val.get_bool()
def set_bool(key,val):
@@ -366,7 +366,7 @@ def get_int(key,correct_tuple=None):
else:
val = client.get_default_from_schema(key)
if val == None:
raise ErrorSchemaInvalid, "No default value for key "+key
raise Errors.GConfSchemaError("No default value for key "+key)
return val.get_int()
def set_int(key,val,correct_tuple=None):
@@ -383,7 +383,7 @@ def get_string(key,test_func=None):
else:
val = client.get_default_from_schema(key)
if val == None:
raise ErrorSchemaInvalid, "No default value for key "+key
raise Errors.GConfSchemaError("No default value for key "+key)
return val.get_string()
def set_string(key,val,test_func=None):

View File

@@ -154,13 +154,6 @@ documenters = [
translators = _('TRANSLATORS: Translate this to your name in your native language')
#-------------------------------------------------------------------------
#
# custom exception
#
#-------------------------------------------------------------------------
ErrorSchemaInvalid = "GConf schema not properly installed"
#-------------------------------------------------------------------------
#
# Constants