List:NDB Connectors« Previous MessageNext Message »
From:Monty Taylor Date:May 1 2007 10:55pm
Subject:Rev 91: Added custom exceptions using NDB_exception instead of SWIG_exception. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/exception...
View as plain text  
------------------------------------------------------------
revno: 91
revision-id: mtaylor@stripped
parent: mtaylor@stripped
committer: Monty Taylor <mtaylor@stripped>
branch nick: exceptions
timestamp: Tue 2007-05-01 15:50:04 -0700
message:
  Added custom exceptions using NDB_exception instead of SWIG_exception.
  Custom exceptions are working and implemented in Java and Python.
  In Perl, the exception name is appended to the message string. 
  Throwing and catching work in Java and Python. 
  Renamed test2.java to testasync.java to better indicate what it tests.
  Added exception catching to test.py and test.java.
  Build python with swig optimizations (-0).
renamed:
  java/test2.java => java/testasync.java test2.java-20070305174931-p3qddjy9i6h6y1f3-4
modified:
  java/Makefile.am               makefile.am-20070415032352-9dpe6aurqcnuwcrd-1
  java/ndbapi.i                  ndbapi.i-20070130002924-gcvhapmvh0lu1pkd-3
  java/test.java                 test.java-20070130002924-gcvhapmvh0lu1pkd-4
  perl/ndbapi.i                  ndb.i-20070225155255-5ief7aicto319mbu-1
  python/ndbapi.i               
svn-v2:1@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-python%2fndb.i
  python/setup.cfg.in           
svn-v2:1@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-python%2fsetup.cfg
  python/test.py                
svn-v2:1@5fca6d9a-db22-0410-b55c-899b0a28da89-trunk-python%2ftest.py
  swig/Ndb.i                     ndb.i-20070228021421-qkr4cbpxymyqdrf3-1
  swig/NdbBlob.i                 ndbblob.i-20070320103812-m6vddks4sg20gnqv-1
  swig/NdbClusterConnection.i    ndb_cluster_connecti-20070228021421-qkr4cbpxymyqdrf3-6
  swig/NdbDictionary.i           ndbdictionary.i-20070323110251-l7mg72hiddtuzeh0-1
  swig/NdbIndexOperation.i       ndbindexoperation.i-20070426125056-cdc2fzutv5osp12a-1
  swig/NdbOperation.i            ndboperation.i-20070228021421-qkr4cbpxymyqdrf3-3
  swig/NdbScanOperation.i        ndbscanoperation.i-20070228021421-qkr4cbpxymyqdrf3-5
  swig/NdbTransaction.i          ndbtransaction.i-20070227184716-ecjyhh3jgvmye4de-7
  swig/globals.i                 globals.i-20070228021421-qkr4cbpxymyqdrf3-7
  java/testasync.java            test2.java-20070305174931-p3qddjy9i6h6y1f3-4
=== renamed file 'java/test2.java' => 'java/testasync.java'
--- a/java/test2.java	2007-04-28 06:52:48 +0000
+++ b/java/testasync.java	2007-05-01 22:50:04 +0000
@@ -6,7 +6,7 @@
 import com.mysql.cluster.ndbapi.*;
 
 
-public class test2 { 
+public class testasync { 
 
   private static Date beginTime;
   private static Date initEndTime;
@@ -19,10 +19,10 @@
 
   private Connection conn; 
 
-/*  static { 
-    System.loadLibrary("ndbapi");
+  static { 
+    System.loadLibrary("ndbj");
   }
-*/
+
 
   public static void main(String argv[]) throws SQLException{ 
 
@@ -35,7 +35,7 @@
     INSERT_NUM = Integer.parseInt(argv[1]);
     int BATCH_SIZE=100;
 
-    ndbapi.ndb_init();
+    //ndbapi.ndb_init();
 
     /**************************************************************
      * Connect to mysql server and create table                   *
@@ -83,7 +83,7 @@
       System.out.println("Connect to cluster management server failed.");
       System.exit(-1);
     }
-    } catch (RuntimeException e) { 
+    } catch (NdbApiException e) { 
       System.out.println(e.getMessage());
       System.exit(-1);
     }

=== modified file 'java/Makefile.am'
--- a/java/Makefile.am	2007-04-28 06:52:48 +0000
+++ b/java/Makefile.am	2007-05-01 22:50:04 +0000
@@ -10,6 +10,7 @@
 lib_LTLIBRARIES = libndbj.la libmgmj.la
 libndbj_la_SOURCES = $(NDBAPT_BUILT_SRC)
 libndbj_la_LIBADD = -lstdc++
+libndbj_la_LDFLAGS = -fpic
 libndbj_la_CPPFLAGS = $(JNI_INCLUDES) $(PTHREAD_CFLAGS)
 libmgmj_la_SOURCES = $(MGMAPI_BUILT_SRC)
 libmgmj_la_CPPFLAGS = $(JNI_INCLUDES) $(PTHREAD_CFLAGS)
@@ -17,8 +18,8 @@
 %_wrap.cxx: %.i
 	$(SWIG) -java -outdir ${package_namespace}/$* -package `echo ${package_namespace}/$* |
sed 's,/,.,g'` -I$(SWIG_DIR) $(MYSQL_INCLUDES) -o $@ $<
 
-test.class: libndbj.la test.java test2.java TestCallback.java
${package_namespace}/ndbapi/ndbapi.jar
+test.class: libndbj.la test.java testasync.java TestCallback.java
${package_namespace}/ndbapi/ndbapi.jar
 	$(JAVAC) -classpath
.:lib/mysql-connector-java-5.0.4-bin.jar:${package_namespace}/ndbapi/ndbapi.jar *java
 
 run: test.class
-	LD_LIBRARY_PATH=".:.libs" java -classpath
.:lib/mysql-connector-java-5.0.4-bin.jar:${package_namespace}/ndbapi/ndbapi.jar test2 3
100
+	LD_LIBRARY_PATH=".:.libs" java -classpath
.:lib/mysql-connector-java-5.0.4-bin.jar:${package_namespace}/ndbapi/ndbapi.jar test 3
100

=== modified file 'java/ndbapi.i'
--- a/java/ndbapi.i	2007-04-28 06:52:48 +0000
+++ b/java/ndbapi.i	2007-05-01 22:50:04 +0000
@@ -55,7 +55,7 @@
 
 }
 
-#define NDB_exception(excp, msg) { ndb_throw_exception(jenv, excp,msg); SWIG_fail; }
+#define NDB_exception(excp, msg) { ndb_throw_exception(jenv, #excp,msg); } 
 
 void ndb_throw_exception(JNIEnv *jenv, const char * excp, const char *msg) { 
   const char * prefix = "com/mysql/cluster/ndbapi/";
@@ -64,7 +64,7 @@
   strcat(exception,excp);
 
   jclass clazz = jenv->FindClass(exception);
-  env->ThrowNew(clazz,msg);
+  jenv->ThrowNew(clazz,msg);
 }
  %}
 
@@ -83,6 +83,7 @@
 %typemap(jtype) asynch_callback_t * "Object"
 %typemap(jstype) asynch_callback_t * "INdbCallable"
 %typemap(javain) asynch_callback_t * "(Object)$javainput"
+/*
 
 %pragma(java) modulecode=%{
   static {
@@ -95,8 +96,11 @@
     ndbapi.ndb_init();
   }
 %}
-
+*/
 %include "NdbFactory.i"
+
+%javaexception("com.mysql.cluster.ndbapi.NdbApiException")
Ndb_cluster_connection::connect;
+
 %include "NdbClusterConnection.i"
 %include "Ndb.i"
 %include "NdbTransaction.i"

=== modified file 'java/test.java'
--- a/java/test.java	2007-04-28 06:52:48 +0000
+++ b/java/test.java	2007-05-01 22:50:04 +0000
@@ -19,9 +19,10 @@
 
   private Connection conn; 
 
+
   static { 
     System.loadLibrary("ndbj");
-    ndbapi.ndb_init();
+    //ndbapi.ndb_init();
   }
 
 
@@ -79,11 +80,11 @@
     NdbClusterConnection connection = NdbFactory.createNdbClusterConnection();
 
     try {
-    if (connection.connect(5,3,1)==-1) { 
+    if (connection.connect(1,1,1)==-1) { 
       System.out.println("Connect to cluster management server failed.");
       System.exit(-1);
     }
-    } catch (RuntimeException e) { 
+    } catch (NdbApiException e) { 
       System.out.println(e.getMessage());
       System.exit(-1);
     }

=== modified file 'perl/ndbapi.i'
--- a/perl/ndbapi.i	2007-04-28 06:52:48 +0000
+++ b/perl/ndbapi.i	2007-05-01 22:50:04 +0000
@@ -3,7 +3,7 @@
 %include "globals.i"
 %{
 
-#define NDB_exception(excp, msg) do { sv_setpvf(GvSV(PL_errgv),"%s %s\n", excp, msg);
SWIG_fail; } while (0)
+#define NDB_exception(excp, msg) do { sv_setpvf(GvSV(PL_errgv),#excp " %s\n", msg);
SWIG_fail; } while (0)
 
 #include <my_global.h>
 

=== modified file 'python/ndbapi.i'
--- a/python/ndbapi.i	2007-04-28 06:52:48 +0000
+++ b/python/ndbapi.i	2007-05-01 22:50:04 +0000
@@ -21,11 +21,26 @@
 
 %include "globals.i"
 
+/*class NdbApiException { 
+  private:
+    NdbApiException();
+    ~NdbApiException();
+};*/
 
 %pythoncode %{ 
 
-class NdbApiException(Exception):
-  pass
+NdbApiException=_ndbapi.NdbApiException
+NdbApiPermanentException=_ndbapi.NdbApiPermanentException
+BlobUndefinedException=_ndbapi.BlobUndefinedException
+NdbApiRuntimeException=_ndbapi.NdbApiRuntimeException
+NdbApiTemporaryException=_ndbapi.NdbApiTemporaryException
+NdbApiTimeStampOutOfBoundsException=_ndbapi.NdbApiTimeStampOutOfBoundsException
+NdbApiUserErrorPermanentException=_ndbapi.NdbApiUserErrorPermanentException
+NdbClusterConnectionPermanentException=_ndbapi.NdbClusterConnectionPermanentException
+NdbClusterConnectionTemporaryException=_ndbapi.NdbClusterConnectionTemporaryException
+NoSuchColumnException=_ndbapi.NoSuchColumnException
+NoSuchIndexException=_ndbapi.NoSuchIndexException
+NoSuchTableException=_ndbapi.NoSuchTableException
 
 def connect(connectstring=None,no_retries=0,retry_delay_in_seconds=1,
            
verbose=0,timeout_for_first_alive=1,timeout_after_first_alive=1,*args,**kwargs):
@@ -65,11 +80,26 @@
    Py_DECREF(arglist);                           // Trash arglist
 }
 
+#define NEW_pyexcept(EXCPT,EPARENT) { PyExc_ ## EXCPT =
PyErr_NewException("mysql.cluster.ndbapi." #EXCPT ,EPARENT,NULL); PyDict_SetItemString(d,
#EXCPT ,PyExc_ ## EXCPT); Py_INCREF(PyExc_ ## EXCPT); }
+
+PyObject * PyExc_NdbApiException; 
+PyObject * PyExc_BlobUndefinedException;
+PyObject * PyExc_NdbApiPermanentException;
+PyObject * PyExc_NdbApiRuntimeException;
+PyObject * PyExc_NdbApiTemporaryException;
+PyObject * PyExc_NdbApiTimeStampOutOfBoundsException;
+PyObject * PyExc_NdbApiUserErrorPermanentException;
+PyObject * PyExc_NdbClusterConnectionPermanentException;
+PyObject * PyExc_NdbClusterConnectionTemporaryException;
+PyObject * PyExc_NoSuchColumnException;
+PyObject * PyExc_NoSuchIndexException;
+PyObject * PyExc_NoSuchTableException;
+
 #define NDB_exception(excp, msg) { ndb_throw_exception(excp,msg); SWIG_fail; }
 
-void ndb_throw_exception(const char * excp_mod, const char * msg) { 
+void ndb_throw_exception(NdbException excp_mod, const char * msg) { 
 
-  char * exception = (char *)malloc(strlen(excp_mod)+22);
+  /*char * exception = (char *)malloc(strlen(excp_mod)+22);
   strcpy(exception, "mysql.cluster.ndbapi.");
   strcat(exception,excp_mod);
   PyObject * PyExc_NdbException = PyErr_NewException(exception,NULL,NULL);
@@ -78,7 +108,52 @@
   } else { 
     PyErr_SetString(PyExc_NdbException,msg);
   }
+  */
+  PyObject * exception; 
   
+  switch (excp_mod) { 
+    case NdbApiException:
+      exception = PyExc_NdbApiException;
+      break; 
+    case BlobUndefinedException:
+      exception = PyExc_BlobUndefinedException;
+      break;
+    case NdbApiPermanentException:
+      exception = PyExc_NdbApiPermanentException;
+      break;
+    case NdbApiRuntimeException:
+      exception = PyExc_NdbApiRuntimeException;
+      break;
+    case NdbApiTemporaryException:
+      exception = PyExc_NdbApiTemporaryException;
+      break;
+    case NdbApiTimeStampOutOfBoundsException:
+      exception = PyExc_NdbApiTimeStampOutOfBoundsException;
+      break;
+    case NdbApiUserErrorPermanentException:
+      exception = PyExc_NdbApiUserErrorPermanentException;
+      break;
+    case NdbClusterConnectionPermanentException:
+      exception = PyExc_NdbClusterConnectionPermanentException;
+      break;
+    case NdbClusterConnectionTemporaryException:
+      exception = PyExc_NdbClusterConnectionTemporaryException;
+      break;
+    case NoSuchColumnException:
+      exception = PyExc_NoSuchColumnException;
+      break;
+    case NoSuchIndexException:
+      exception = PyExc_NoSuchIndexException;
+      break;
+    case NoSuchTableException:
+      exception = PyExc_NoSuchTableException;
+      break;
+    default:
+      exception = PyExc_RuntimeError;
+  }
+  exception = PyExc_NdbApiException;
+  PyErr_SetString(exception,msg);
+  Py_INCREF(exception);  
 }
 
 %}
@@ -96,16 +171,36 @@
 %extend NdbTransaction { 
   void executeAsynchPrepare(ExecType          execType,
                             PyObject*         pyfunc,
-                            AbortOption       abortOption = AbortOnError)
+                            AbortOption       abortOption = AbortOnError) 
   {
     self->executeAsynchPrepare(execType,PythonCallBack,(void *)pyfunc,abortOption); 
     Py_INCREF(pyfunc);
   };
 };
 
-
 %init %{
-        ndb_init();
+  // PyObject *m, *d; - m==module d==module.__dict__
+  ndb_init();
+  
+/*
+  PyExc_NdbApiException =
PyErr_NewException("mysql.cluster.ndbapi.NdbApiException",NULL,NULL);
+  PyDict_SetItemString(d,"NdbApiException",PyExc_NdbApiException);
+  Py_INCREF(PyExc_NdbApiException);
+*/
+  NEW_pyexcept(NdbApiException,NULL);
+  NEW_pyexcept(NdbApiRuntimeException,PyExc_NdbApiException);
+  NEW_pyexcept(NdbApiPermanentException,PyExc_NdbApiException);
+  NEW_pyexcept(NdbApiTemporaryException,PyExc_NdbApiException);
+  NEW_pyexcept(NdbApiUserErrorPermanentException,PyExc_NdbApiPermanentException);
+  NEW_pyexcept(NdbClusterConnectionPermanentException,PyExc_NdbApiPermanentException);
+  NEW_pyexcept(NdbClusterConnectionTemporaryException,PyExc_NdbApiTemporaryException);
+  NEW_pyexcept(NdbApiTimeStampOutOfBoundsException,PyExc_NdbApiException);
+  NEW_pyexcept(BlobUndefinedException,PyExc_NdbApiException);
+  NEW_pyexcept(NoSuchColumnException,PyExc_NdbApiException);
+  NEW_pyexcept(NoSuchIndexException,PyExc_NdbApiException);
+  NEW_pyexcept(NoSuchTableException,PyExc_NdbApiException);
+
+
 %}
 
 %feature("shadow") NdbOperation::setValue %{

=== modified file 'python/setup.cfg.in'
--- a/python/setup.cfg.in	2007-03-26 15:08:03 +0000
+++ b/python/setup.cfg.in	2007-05-01 22:50:04 +0000
@@ -6,5 +6,5 @@
 [build_ext]
 # There is current a bug in distutils that makes us set this here and not in 
 # setup.py - which is a problem, because that's where we figure these out
-swig_opts = -c++ -DDOXYGEN_SHOULD_SKIP_INTERNAL -DMYSQL_@MYSQL_MAJOR_VERSION@
@MYSQL_INCLUDES@ -I../swig -outdir mysql/cluster
+swig_opts = -c++ -O -DDOXYGEN_SHOULD_SKIP_INTERNAL -DMYSQL_@MYSQL_MAJOR_VERSION@
@MYSQL_INCLUDES@ -I../swig -outdir mysql/cluster
 

=== modified file 'python/test.py'
--- a/python/test.py	2007-04-28 06:52:48 +0000
+++ b/python/test.py	2007-05-01 22:50:04 +0000
@@ -1,5 +1,9 @@
 import sys,time,random,struct,math
 from mysql.cluster import ndbapi
+import mysql.cluster.ndbapi
+
+e=mysql.cluster.ndbapi.NdbApiException()
+print e
 
 import  MySQLdb
 
@@ -36,9 +40,13 @@
 
 print "connecting to cluster\n"
    
-connection = ndbapi.NdbFactory.createNdbClusterConnection();
+try:
+  connection = ndbapi.NdbFactory.createNdbClusterConnection();
 
-connection.connect(1,1,1)
+  connection.connect(1,1,1)
+except mysql.cluster.ndbapi.NdbApiException,e:
+  print "Couldn't connect to cluster"
+  sys.exit(-1)
 
 if (connection.wait_until_ready(30,30)):
     print "Cluster was not ready within 30 secs."

=== modified file 'swig/Ndb.i'
--- a/swig/Ndb.i	2007-04-28 06:52:48 +0000
+++ b/swig/Ndb.i	2007-05-01 22:50:04 +0000
@@ -41,7 +41,7 @@
     $action
       if (result==-1) { 
 	NdbError err = arg1->getNdbError();
-	NDB_exception("NdbApiException",err.message);
+	NDB_exception(NdbApiException,err.message);
       }
   }
   int  sendPollNdb(int aMillisecondNumber = WAITFOR_RESPONSE_TIMEOUT,
@@ -52,7 +52,7 @@
     $action
       if (result==NULL) { 
         NdbError err = arg1->getNdbError();
-	NDB_exception("NdbApiException",err.message);
+	NDB_exception(NdbApiException,err.message);
       }
   }
   NdbTransaction* startTransaction(const NdbDictionary::Table *table= 0,
@@ -62,7 +62,7 @@
   %exception init { 
     $action
       if (result) { 
-	NDB_exception("NdbApiException","Cluster not ready");
+	NDB_exception(NdbApiException,"Cluster not ready");
       }
   }
   int init(int maxNoOfTransactions = 4);
@@ -71,7 +71,7 @@
     $action
       if (result == 0) { 
 	NdbError err = arg1->getNdbError();
-	NDB_exception("NdbApiException",err.message);
+	NDB_exception(NdbApiException,err.message);
       }
   }
   int getAutoIncrementValue(const char* aTableName, 

=== modified file 'swig/NdbBlob.i'
--- a/swig/NdbBlob.i	2007-04-28 06:52:48 +0000
+++ b/swig/NdbBlob.i	2007-05-01 22:50:04 +0000
@@ -16,7 +16,7 @@
     $action
       if (result==-1) { 
         NdbError err = arg1->getNdbError();
-	NDB_exception("NdbApiException", err.message);
+	NDB_exception(NdbApiException, err.message);
       }
   }
   int getValue(char* data, Uint32 bytes);
@@ -39,7 +39,7 @@
     $action
       if (result==0) { 
         NdbError err = arg1->getNdbError();
-	NDB_exception("NdbApiException", err.message);
+	NDB_exception(NdbApiException, err.message);
       }
   }
 
@@ -60,7 +60,7 @@
 	int ret=self->readData(data, b);
 	if (ret==-1) {
 		NdbError err = self->getNdbError();
-		NDB_exception("NdbApiException", err.message);
+		NDB_exception(NdbApiException, err.message);
 	}
 	return b;
 fail:

=== modified file 'swig/NdbClusterConnection.i'
--- a/swig/NdbClusterConnection.i	2007-04-28 06:52:48 +0000
+++ b/swig/NdbClusterConnection.i	2007-05-01 22:50:04 +0000
@@ -30,14 +30,14 @@
     $action
       if (result) { 
 	const char * msg = "Connect to management server failed"; 
-	NDB_exception("NdbApiException",msg);
+	NDB_exception(NdbApiException,msg);
       }
   }
   %exception wait_until_ready { 
     $action
       if (result) { 
         const char * msg = "Cluster was not ready";
-	NDB_exception("NdbApiException",msg);
+	NDB_exception(NdbApiException,msg);
       }
   }
 
@@ -52,7 +52,7 @@
   %exception getNdb { 
     $action
       if (result==NULL) { 
-	NDB_exception("NdbApiException","Couldn't allocate an Ndb object");
+	NDB_exception(NdbApiException,"Couldn't allocate an Ndb object");
       }
   }
   Ndb* getNdb(const char* aCatalogName="", const char* aSchemaName="def") {

=== modified file 'swig/NdbDictionary.i'
--- a/swig/NdbDictionary.i	2007-04-28 06:52:48 +0000
+++ b/swig/NdbDictionary.i	2007-05-01 22:50:04 +0000
@@ -308,7 +308,7 @@
     $action
       if (result==NULL) { 
         NdbError err = arg1->getNdbError();
-        NDB_exception("NdbApiException",err.message);
+        NDB_exception(NdbApiException,err.message);
       }
   }
     const NdbDictionary::Table * getTable(const char * name) const;
@@ -323,7 +323,7 @@
     $action
       if (result==-1) { 
         NdbError err = arg1->getNdbError();
-	NDB_exception("NdbApiException",err.message);
+	NDB_exception(NdbApiException,err.message);
       }
   }
 #if 0

=== modified file 'swig/NdbIndexOperation.i'
--- a/swig/NdbIndexOperation.i	2007-04-28 06:52:48 +0000
+++ b/swig/NdbIndexOperation.i	2007-05-01 22:50:04 +0000
@@ -21,7 +21,7 @@
     $action
       if (result==-1) { 
         NdbError err = arg1->getNdbError();
-	NDB_exception("NdbApiException",err.message);
+	NDB_exception(NdbApiException,err.message);
       }
   }
 
@@ -39,7 +39,7 @@
     $action
       if (result==0) { 
         NdbError err = arg1->getNdbError();
-	NDB_exception("NdbApiException",err.message);
+	NDB_exception(NdbApiException,err.message);
       }
   }
 

=== modified file 'swig/NdbOperation.i'
--- a/swig/NdbOperation.i	2007-04-28 06:52:48 +0000
+++ b/swig/NdbOperation.i	2007-05-01 22:50:04 +0000
@@ -150,7 +150,7 @@
     $action
       if (result == NULL) { 
         NdbError err = arg1->getNdbError();
-	NDB_exception("NdbApiException",err.message);
+	NDB_exception(NdbApiException,err.message);
       }
   }
   NdbRecAttr* getValue(const char* anAttrName);
@@ -164,7 +164,7 @@
     $action
       if (result==-1) { 
         NdbError err = arg1->getNdbError();
-        NDB_exception("NdbApiException",err.message);
+        NDB_exception(NdbApiException,err.message);
       }
   }
 
@@ -323,7 +323,7 @@
     $action
       if (result==-1) { 
         NdbError err = arg1->getNdbError();
-        NDB_exception("NdbApiException",err.message);
+        NDB_exception(NdbApiException,err.message);
       }
   }
 

=== modified file 'swig/NdbScanOperation.i'
--- a/swig/NdbScanOperation.i	2007-04-28 06:52:48 +0000
+++ b/swig/NdbScanOperation.i	2007-05-01 22:50:04 +0000
@@ -33,7 +33,7 @@
     $action
       if (result==-1) { 
         NdbError err = arg1->getNdbError();
-	NDB_exception("NdbApiException",err.message);
+	NDB_exception(NdbApiException,err.message);
       }
   }
 
@@ -48,7 +48,7 @@
     $action
       if (result==0) { 
         NdbError err = arg1->getNdbError();
-	NDB_exception("NdbApiException",err.message);
+	NDB_exception(NdbApiException,err.message);
       }
   }
 

=== modified file 'swig/NdbTransaction.i'
--- a/swig/NdbTransaction.i	2007-04-28 06:52:48 +0000
+++ b/swig/NdbTransaction.i	2007-05-01 22:50:04 +0000
@@ -31,7 +31,7 @@
     $action
       if (result==NULL) { 
         NdbError err = arg1->getNdbError();
-        NDB_exception("NdbApiException",err.message);
+        NDB_exception(NdbApiException,err.message);
       }
   }
   NdbOperation* getNdbOperation(const class NdbDictionary::Table* aTable);
@@ -48,7 +48,7 @@
     $action
       if (result==-1) { 
         NdbError err = arg1->getNdbError();
-	NDB_exception("NdbApiException",err.message);
+	NDB_exception(NdbApiException,err.message);
       }
   }
   int execute(ExecType execType,

=== modified file 'swig/globals.i'
--- a/swig/globals.i	2007-04-28 06:52:48 +0000
+++ b/swig/globals.i	2007-05-01 22:50:04 +0000
@@ -5,6 +5,22 @@
 
 %{
 #include <NdbApi.hpp> 
+
+enum NdbException {
+    NdbApiException,
+    BlobUndefinedException,
+    NdbApiPermanentException,
+    NdbApiRuntimeException,
+    NdbApiTemporaryException,
+    NdbApiTimeStampOutOfBoundsException,
+    NdbApiUserErrorPermanentException,
+    NdbClusterConnectionPermanentException,
+    NdbClusterConnectionTemporaryException,
+    NoSuchColumnException,
+    NoSuchIndexException,
+    NoSuchTableException,
+};
+
 %}
 
 %include "ndb_constants.h"

Thread
Rev 91: Added custom exceptions using NDB_exception instead of SWIG_exception. in http://bazaar.launchpad.net/~ndb-connectors/ndb-connectors/exception...Monty Taylor2 May