File: mserror.i

package info (click to toggle)
mapserver 4.10.0-5.1%2Betch4
  • links: PTS
  • area: main
  • in suites: etch
  • size: 12,264 kB
  • ctags: 15,165
  • sloc: ansic: 164,837; sh: 6,141; python: 5,770; java: 5,169; perl: 2,388; cpp: 1,603; makefile: 735; lex: 507; yacc: 317; tcl: 158; cs: 85; ruby: 53
file content (64 lines) | stat: -rw-r--r-- 2,056 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* 
===========================================================================
 $Id: mserror.i,v 1.3 2006/03/16 22:30:29 tamas Exp $
 
 Project:  MapServer
 Purpose:  MapScript exceptions
 Author:   Umberto Unicoletti, unicoletti@prometeo.it
           Jerry Pisk, jerry.pisk@gmail.com
           Sean Gillies, sgillies@frii.com
           Tamas Szekeres, szekerest@gmail.com

 Note: Python exceptions are in mapscript/python
       C# exceptions are redefinied in mapscript/csharp
       
       This implementation truncates the error message length
       to MAX_ERROR_LEN since SWIG_exception does not allow
       to free memory allocated on the heap easily (szekerest)
============================================================================
*/
#define MAX_ERROR_LEN 8192
%include exception.i

%exception {
    errorObj *ms_error;
    $action
    ms_error = msGetErrorObj();
    if (ms_error!=NULL && ms_error->code != MS_NOERR) {
        char ms_message[MAX_ERROR_LEN];
        char* msg = msGetErrorString(";");
        int ms_errorcode = ms_error->code;
        if (msg) {
			snprintf(ms_message, MAX_ERROR_LEN, msg);
			free(msg);
		}
        else sprintf(ms_message, "Unknown message");

        msResetErrorList();
       
        switch(ms_errorcode) {
            case MS_NOTFOUND:
                break;
            case -1:
                break;
            case MS_IOERR:
                SWIG_exception(SWIG_IOError ,ms_message);
                break;
            case MS_MEMERR:
                SWIG_exception(SWIG_MemoryError,ms_message);
                break;
            case MS_TYPEERR:
                SWIG_exception(SWIG_TypeError,ms_message);
                break;
            case MS_EOFERR:
                SWIG_exception(SWIG_SyntaxError,ms_message);
                break;
            case MS_CHILDERR:
                SWIG_exception(SWIG_SystemError,ms_message);
                break;
            default:
                SWIG_exception(SWIG_UnknownError,ms_message);
                break;
        }       
    }
}