diff options
| author | Emmanuel Raviart <eraviart@entrouvert.com> | 2004-08-29 08:31:59 +0000 |
|---|---|---|
| committer | Emmanuel Raviart <eraviart@entrouvert.com> | 2004-08-29 08:31:59 +0000 |
| commit | 51adf42fdc0cec17e5e4420aa36e1d8f75252bac (patch) | |
| tree | ab63af9ecab4a231118a860b3f31993427c65587 | |
| parent | b27283f775f6f3ca65c6519427e83861baaf5229 (diff) | |
| download | lasso-51adf42fdc0cec17e5e4420aa36e1d8f75252bac.tar.gz lasso-51adf42fdc0cec17e5e4420aa36e1d8f75252bac.tar.xz lasso-51adf42fdc0cec17e5e4420aa36e1d8f75252bac.zip | |
When Lasso doesn't recognize the URL query, it now throws a SyntaxError
exception.
| -rwxr-xr-x | python/tests/profiles_tests.py | 4 | ||||
| -rw-r--r-- | swig/Lasso.i | 60 |
2 files changed, 42 insertions, 22 deletions
diff --git a/python/tests/profiles_tests.py b/python/tests/profiles_tests.py index 6aba8e80..0fced9e6 100755 --- a/python/tests/profiles_tests.py +++ b/python/tests/profiles_tests.py @@ -151,8 +151,8 @@ class DefederationTestCase(unittest.TestCase): # The process_notification_msg should failt but not abort. try: defederation.process_notification_msg('nonLibertyQuery=1', lasso.httpMethodRedirect) - except RuntimeError, error: - errorCode = int(error.args[0].split(' ', 1)[0]) + except SyntaxError: + pass else: self.fail('Defederation process_notification_msg should have failed.') diff --git a/swig/Lasso.i b/swig/Lasso.i index f7d1dac3..8b227277 100644 --- a/swig/Lasso.i +++ b/swig/Lasso.i @@ -47,6 +47,9 @@ #include <lasso/lasso_config.h> #include <lasso/lasso.h> +/* FIXME: IMHO, Lasso errors should not be defined in lasso/xml/ */ +/* and should be included in lasso.h. */ +#include <lasso/xml/errors.h> /* @@ -117,25 +120,6 @@ %typemap(newfree) gchar * "g_free($1);"; %typemap(newfree) xmlChar * "xmlFree($1);"; -/* Generate a language independant exception from Lasso function result. */ - -%define THROW_ERROR -%exception { - int errorCode; - errorCode = $action - if (errorCode) { - char errorMessage[256]; - sprintf(errorMessage, "%d (Lasso error)", errorCode); - SWIG_exception(SWIG_UnknownError, errorMessage); - } -} -%enddef - -%define END_THROW_ERROR -%exception; -%enddef - - /* Functions */ %rename(init) lasso_init; @@ -297,7 +281,11 @@ typedef enum { } lassoSignatureMethod; -/* Errors */ +/*********************************************************************** + * Errors + ***********************************************************************/ + + %rename(XML_ERROR_NODE_NOT_FOUND) LASSO_XML_ERROR_NODE_NOT_FOUND; #define LASSO_XML_ERROR_NODE_NOT_FOUND -10 %rename(XML_ERROR_NODE_CONTENT_NOT_FOUND) LASSO_XML_ERROR_NODE_CONTENT_NOT_FOUND; @@ -351,6 +339,38 @@ typedef enum { %rename(ERROR_UNDEFINED) LASSO_ERROR_UNDEFINED; #define LASSO_ERROR_UNDEFINED -999 +/* Generate a language independant exception from Lasso error codes. */ + +%{ + +int get_exception_type(int errorCode) +{ + if (errorCode == LASSO_PROFILE_ERROR_INVALID_QUERY) + return SWIG_SyntaxError; + else + return SWIG_UnknownError; +} + +%} + +/* Wrappers for Lasso functions that return an error code. */ + +%define THROW_ERROR +%exception { + int errorCode; + errorCode = $action + if (errorCode) { + char errorMessage[256]; + sprintf(errorMessage, "%d / Lasso Error", errorCode); + SWIG_exception(get_exception_type(errorCode), errorMessage); + } +} +%enddef + +%define END_THROW_ERROR +%exception; +%enddef + /*********************************************************************** *********************************************************************** |
