r19808 - gnucash/trunk/src/optional/python-bindings - Bug #634812: Improve backend error reporting for Session begin

Christian Stimming cstim at code.gnucash.org
Sun Nov 14 08:30:16 EST 2010


Author: cstim
Date: 2010-11-14 08:30:16 -0500 (Sun, 14 Nov 2010)
New Revision: 19808
Trac: http://svn.gnucash.org/trac/changeset/19808

Modified:
   gnucash/trunk/src/optional/python-bindings/gnucash_core.py
Log:
Bug #634812: Improve backend error reporting for Session begin

Patch by Mike E:

The current error feedback to a python scrpt/user looks something like:

call to begin resulted in the following errors, (7,)

This change in gnucash_core.py makes the feedback similar to:

call to begin resulted in the following errors, ERR_BACKEND_LOCKED

This is less cryptic and aid debugging of user python scripts.  My only
issue though is whether this would break existing user scripts where checking
of this error code is used for flow control.  Although since the ERR_ codes are
imported with gnucash_core_c it *should* have no effect.

Modified: gnucash/trunk/src/optional/python-bindings/gnucash_core.py
===================================================================
--- gnucash/trunk/src/optional/python-bindings/gnucash_core.py	2010-11-14 13:16:31 UTC (rev 19807)
+++ gnucash/trunk/src/optional/python-bindings/gnucash_core.py	2010-11-14 13:30:16 UTC (rev 19808)
@@ -111,7 +111,7 @@
         if errors != ():
             raise GnuCashBackendException(
                 "call to %s resulted in the "
-                "following errors, %s" % (called_function, errors),
+                "following errors, %s" % (called_function, backend_error_dict[errors[0]]),
                 errors )        
 
     def generate_errors(self):
@@ -349,6 +349,12 @@
     extract_attributes_with_prefix(gnucash_core_c, 'ERR_'):
     this_module_dict[ error_name ] = error_value
 
+#backend error codes used for reverse lookup
+backend_error_dict = {}
+for error_name, error_value, error_name_after_prefix in \
+    extract_attributes_with_prefix(gnucash_core_c, 'ERR_'):
+    backend_error_dict[ error_value ] = error_name
+
 # GncNumeric demoniminator computation schemes
 # Used for the denom argument in arithmetic functions like GncNumeric.add
 from gnucash.gnucash_core_c import GNC_DENOM_AUTO



More information about the gnucash-changes mailing list