diff options
| author | Frederic Peters <fpeters@entrouvert.com> | 2008-04-29 12:07:55 +0000 |
|---|---|---|
| committer | Frederic Peters <fpeters@entrouvert.com> | 2008-04-29 12:07:55 +0000 |
| commit | 52c7f0902468c00e6b2f6bfd4882dd132558a7cb (patch) | |
| tree | 0933129c61aa7ce5402f60a1d69b22235583dfc4 | |
| parent | cfe90cf622a1714cee531ce819c83ad39281d3f9 (diff) | |
| download | lasso-52c7f0902468c00e6b2f6bfd4882dd132558a7cb.tar.gz lasso-52c7f0902468c00e6b2f6bfd4882dd132558a7cb.tar.xz lasso-52c7f0902468c00e6b2f6bfd4882dd132558a7cb.zip | |
[project @ fpeters@0d.be-20080229163949-v7zjjcr3sg5w0wfj]
set exception code in raise_on_rc as the same exception can share two different
codes (in reality this is only the case for UnknownProfileError), also skip
LogoutErroor/UnknownProfileError instead of duplicating and overwriting it,
with a long explanation comment.
Original author: Frederic Peters <fpeters@0d.be>
Date: 2008-02-29 17:39:49.202000+01:00
| -rw-r--r-- | bindings/lang_python.py | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/bindings/lang_python.py b/bindings/lang_python.py index d58c7cac..5464cc52 100644 --- a/bindings/lang_python.py +++ b/bindings/lang_python.py @@ -105,7 +105,12 @@ class Error(Exception): @staticmethod def raise_on_rc(rc): global exceptions_dict - raise exceptions_dict.get(rc) + exception = exceptions_dict.get(rc) + if not exception: + raise LassoError() + else: + exception.code = rc + raise exception def __str__(self): return '<lasso.%s(%s): %s>' % (self.__class__.__name__, self.code, _lasso.strError(self.code)) @@ -151,12 +156,23 @@ class %sError(%sError): pass ''' % (cat, parent_cat) + exceptions_dict[detail] = c[1][6:] + + if (detail, cat) == ('UnsupportedProfile', 'Logout'): + # skip Logout/UnsupportedProfile exception as its name would + # be the same as Profile/UnsupportedProfile; it is not a + # problem skipping it as they both inherit from ProfileError + # and the exception code will correctly be set by raise_on_rc + # afterwards. (actually it is even totally unnecessary to skip + # it here as Profile/UnsupportedProfile is handled after + # Logout/UnsupportedProfile, this is just done in the case the + # ordering would change) + continue + print >> fd, '''\ class %sError(%sError): - code = _lasso.%s -''' % (detail, cat, c[1][6:]) - - exceptions_dict[detail] = c[1][6:] + pass +''' % (detail, cat) print >> fd, 'exceptions_dict = {' for k, v in exceptions_dict.items(): |
