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.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19808 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2010-11-14 13:30:16 +00:00
parent 5816a971ce
commit 807d195242

View File

@ -111,7 +111,7 @@ class Session(GnuCashCoreClass):
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 @@ for error_name, error_value, error_name_after_prefix in \
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