File: mserror.i

package info (click to toggle)
mapserver 5.6.5-2%2Bsqueeze3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 15,900 kB
  • ctags: 25,593
  • sloc: ansic: 201,813; cpp: 49,629; cs: 11,792; python: 5,233; perl: 3,249; sh: 1,199; makefile: 884; lex: 592; java: 466; xml: 373; yacc: 334; tcl: 158; ruby: 53
file content (67 lines) | stat: -rw-r--r-- 2,173 bytes parent folder | download | duplicates (3)
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
65
66
67
/* 
===========================================================================
 $Id: mserror.i 6016 2007-04-17 10:36:55Z umberto $
 
 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;
            case MS_NULLPARENTERR:
                SWIG_exception(SWIG_SystemError,ms_message);
                break;
            default:
                SWIG_exception(SWIG_UnknownError,ms_message);
                break;
        }       
    }
}