7
7
int bUseExceptions=0;
8
CPLErrorHandler pfnPreviousHandler = CPLDefaultErrorHandler;
10
VeryQuietErrorHandler(CPLErr eclass, int code, const char *msg )
11
PythonBindingErrorHandler(CPLErr eclass, int code, const char *msg )
14
** Generally we want to supress error reporting if we have exceptions
15
** enabled as the error message will be in the exception thrown in
12
19
/* If the error class is CE_Fatal, we want to have a message issued
13
20
because the CPL support code does an abort() before any exception
14
21
can be generated */
15
22
if (eclass == CE_Fatal ) {
16
CPLDefaultErrorHandler(eclass, code, msg );
23
pfnPreviousHandler(eclass, code, msg );
27
** We do not want to interfere with warnings or debug messages since
28
** they won't be translated into exceptions.
30
if (eclass == CE_Warning || eclass == CE_Debug ) {
31
pfnPreviousHandler(eclass, code, msg );
38
int GetUseExceptions() {
39
return bUseExceptions;
22
42
void UseExceptions() {
23
43
bUseExceptions = 1;
24
CPLSetErrorHandler( (CPLErrorHandler) VeryQuietErrorHandler );
45
CPLSetErrorHandler( (CPLErrorHandler) PythonBindingErrorHandler );
27
48
void DontUseExceptions() {
28
49
bUseExceptions = 0;
29
CPLSetErrorHandler( CPLDefaultErrorHandler );
50
CPLSetErrorHandler( pfnPreviousHandler );