Skip to content

Commit

Permalink
handle c exceptions in msLoadMapFromString
Browse files Browse the repository at this point in the history
  • Loading branch information
szekerest committed May 2, 2024
1 parent a60763a commit 6221f9e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions mapscript/mapscript.i
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
%ignore layerObj::extent;
#endif

#if !defined(WIN32) || !defined(SWIGCSHARP)
%newobject msLoadMapFromString;
#endif

%{
#include "../../mapserver.h"
Expand Down Expand Up @@ -333,3 +335,19 @@ typedef struct {
%include "rbextend.i"
#endif

#if defined(WIN32) && defined(SWIGCSHARP)
%inline %{
// Wrapper function with exception handling
mapObj *msLoadMapFromString_wrapper(char *buffer, char *new_mappath, const configObj* config) {
__try {
return msLoadMapFromString(buffer, new_mappath, config);
}
__except(EXCEPTION_EXECUTE_HANDLER) {
// Handle the exception here, e.g., set an error message
return NULL;
}
}
%}
%rename(msLoadMapFromString) msLoadMapFromString_wrapper;
#endif

0 comments on commit 6221f9e

Please sign in to comment.