root/tags/rel-5-0-2/mapserver/mapscript/mserror.i

Revision 6016, 2.1 kB (checked in by umberto, 1 year ago)

RFC24: mapObj, layerObj, initial classObj support

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2 ===========================================================================
3  $Id$
4  
5  Project:  MapServer
6  Purpose:  MapScript exceptions
7  Author:   Umberto Unicoletti, unicoletti@prometeo.it
8            Jerry Pisk, jerry.pisk@gmail.com
9            Sean Gillies, sgillies@frii.com
10            Tamas Szekeres, szekerest@gmail.com
11
12  Note: Python exceptions are in mapscript/python
13        C# exceptions are redefinied in mapscript/csharp
14        
15        This implementation truncates the error message length
16        to MAX_ERROR_LEN since SWIG_exception does not allow
17        to free memory allocated on the heap easily (szekerest)
18 ============================================================================
19 */
20 #define MAX_ERROR_LEN 8192
21 %include exception.i
22
23 %exception {
24     errorObj *ms_error;
25     $action
26     ms_error = msGetErrorObj();
27     if (ms_error!=NULL && ms_error->code != MS_NOERR) {
28         char ms_message[MAX_ERROR_LEN];
29         char* msg = msGetErrorString(";");
30         int ms_errorcode = ms_error->code;
31         if (msg) {
32                         snprintf(ms_message, MAX_ERROR_LEN, msg);
33                         free(msg);
34                 }
35         else sprintf(ms_message, "Unknown message");
36
37         msResetErrorList();
38        
39         switch(ms_errorcode) {
40             case MS_NOTFOUND:
41                 break;
42             case -1:
43                 break;
44             case MS_IOERR:
45                 SWIG_exception(SWIG_IOError ,ms_message);
46                 break;
47             case MS_MEMERR:
48                 SWIG_exception(SWIG_MemoryError,ms_message);
49                 break;
50             case MS_TYPEERR:
51                 SWIG_exception(SWIG_TypeError,ms_message);
52                 break;
53             case MS_EOFERR:
54                 SWIG_exception(SWIG_SyntaxError,ms_message);
55                 break;
56             case MS_CHILDERR:
57                 SWIG_exception(SWIG_SystemError,ms_message);
58                 break;
59             case MS_NULLPARENTERR:
60                 SWIG_exception(SWIG_SystemError,ms_message);
61                 break;
62             default:
63                 SWIG_exception(SWIG_UnknownError,ms_message);
64                 break;
65         }       
66     }
67 }
Note: See TracBrowser for help on using the browser.