[openstack-dev] [Glance] Passing error data in Glance exceptions?
kpublicmail at gmail.com
Fri Jan 3 13:45:26 UTC 2014
At the moment the GlanceException class has only a static
"message" member which holds the error string. As a result higher
level modules (e.g. API) are unable to translate a lower level
exception to a more meaningful user-facing message - they either have
to construct a totally new message or reproduce the exception string.
Conversely, lower level modules (e.g. storage backend modules)
need to consider their parameters carefully (e.g. some "reason"
string) if the parameter is some form of free-flowing string (as
against, say, an int value) because the string might be reported to
the end user.
All this seems a little haphazzard.
But if we just tweaked the GlanceException class a little bit to
store the 'args' and 'kwargs' arguments, then the lower level modules
can make their error info available to the higher layers and the
higher layers can do further analysis of the errors reported by the
lower layers and give an appropriate user-facing description of the
error (or simply generate more meaningful logs than just reproducing
what the lower layer already logged).
And I think it will also make testing a little simpler - instead
of testing for assertTrue("spam ham" in exc.message) we can just do
a more precise assertEquals("spam ham", exc.eggs).
What do you all think?
PS: The background to all this is a long exchange we're having in:
I welcome/encourage/request/beg more reviewers to take a look and
chime in their valuable opinions. Many thanks.
More information about the OpenStack-dev