File: mserror.i

package info (click to toggle)
mapserver 6.4.1-5%2Bdeb8u3
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 12,960 kB
  • ctags: 19,791
  • sloc: ansic: 119,501; cpp: 54,044; python: 3,055; xml: 1,676; cs: 875; lex: 741; yacc: 707; java: 588; perl: 428; makefile: 382; sh: 373; tcl: 158; ruby: 55
file content (67 lines) | stat: -rw-r--r-- 2,127 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
65
66
67
/* 
===========================================================================
 $Id$
 
 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;
        }       
    }
}