Wednesday, 5 February 2014

MapGuide tidbits: MgException proxy class in PHP

Here's a nice tidbit I discovered while building the mapguide-rest extension.

The MgException class in the PHP binding to the MapGuide API is also an Exception class. This means it carries its own PHP-land stack trace in addition to the MapGuide one.

What this means is when you catch an MgException in PHP code:

  • Calling GetStackTrace() gives you the C++ code stack trace on the MapGuide Server-side
  • Calling getTraceAsString() (because it's also a PHP Exception class), gives you the stack trace on the PHP side that triggered the MgException on the server-side.
Combine the two outputs and you get a very detailed series of events from both sides of the PHP-Native fence that explain how the MgException came to be thrown.

No comments: