Raise a cx_Oracle.Error instance for invalid handle as well in order to make

debugging of such error messages simpler.
This commit is contained in:
Anthony Tuininga 2008-11-11 20:38:06 +00:00
parent 98f928a819
commit 5b6a9b017a

View File

@ -162,7 +162,7 @@ static void Environment_Free(
// exception for Python. At this point it is assumed that the Oracle // exception for Python. At this point it is assumed that the Oracle
// environment is fully initialized. // environment is fully initialized.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void Environment_RaiseError( static int Environment_RaiseError(
udt_Environment *environment, // environment to raise error for udt_Environment *environment, // environment to raise error for
const char *context) // context in which error occurred const char *context) // context in which error occurred
{ {
@ -197,6 +197,7 @@ static void Environment_RaiseError(
PyErr_SetObject(exceptionType, (PyObject*) error); PyErr_SetObject(exceptionType, (PyObject*) error);
Py_DECREF(error); Py_DECREF(error);
} }
return -1;
} }
@ -210,10 +211,19 @@ static int Environment_CheckForError(
sword status, // status of last call sword status, // status of last call
const char *context) // context const char *context) // context
{ {
udt_Error *error;
if (status != OCI_SUCCESS && status != OCI_SUCCESS_WITH_INFO) { if (status != OCI_SUCCESS && status != OCI_SUCCESS_WITH_INFO) {
if (status == OCI_INVALID_HANDLE) if (status != OCI_INVALID_HANDLE)
PyErr_SetString(g_DatabaseErrorException, "Invalid handle!"); return Environment_RaiseError(environment, context);
else Environment_RaiseError(environment, context); error = Error_New(environment, context, 0);
if (!error)
return -1;
error->code = 0;
error->message = cxString_FromAscii("Invalid handle!");
if (!error->message)
Py_DECREF(error);
else PyErr_SetObject(g_DatabaseErrorException, (PyObject*) error);
return -1; return -1;
} }
return 0; return 0;