summaryrefslogtreecommitdiffstats
path: root/swig
diff options
context:
space:
mode:
authorEmmanuel Raviart <eraviart@entrouvert.com>2004-08-29 08:31:59 +0000
committerEmmanuel Raviart <eraviart@entrouvert.com>2004-08-29 08:31:59 +0000
commit51adf42fdc0cec17e5e4420aa36e1d8f75252bac (patch)
treeab63af9ecab4a231118a860b3f31993427c65587 /swig
parentb27283f775f6f3ca65c6519427e83861baaf5229 (diff)
downloadlasso-51adf42fdc0cec17e5e4420aa36e1d8f75252bac.tar.gz
lasso-51adf42fdc0cec17e5e4420aa36e1d8f75252bac.tar.xz
lasso-51adf42fdc0cec17e5e4420aa36e1d8f75252bac.zip
When Lasso doesn't recognize the URL query, it now throws a SyntaxError
exception.
Diffstat (limited to 'swig')
-rw-r--r--swig/Lasso.i60
1 files changed, 40 insertions, 20 deletions
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
+
/***********************************************************************
***********************************************************************