Autodesk 15606-011408-9300 Developer Guide - Page 48
Checking for Incorrect Argument Types, Debugging an Application
UPC - 606121429548
View all Autodesk 15606-011408-9300 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 48 highlights
To get the most recently called method error code 1 Call the MGMap.getLastError method to get the MGError object. 2 Next call the MGError.getCode method to get the error code. For example: function checkErrorCode() { var map = getMap(); var code = map.getLastError().getCode(); alert("ERROR: " + code); } Checking for Incorrect Argument Types If you call an API method with incorrect argument types, by default, Autodesk MapGuide Viewer has the method do nothing and flags the error in MGError. You can see which argument was incorrect by calling the MGError.getArg method. To check for an incorrect argument type for the most recently called method 1 Call the MGMap.getLastError method to get the MGError object. 2 Next call the MGError.getArg method to get the number of the incorrect argument. For example: function checkArgType() { var map = getMap(); var arg = map.getLastError().getArg(); alert("ERROR: " + arg); } To see the argument types for any API method, locate that method's Help topic in the Autodesk MapGuide Viewer API Help. Debugging an Application In addition to checking MGError, you can call the MGMap.enableApiExceptions and MGMap.disableApiExceptions methods to throw or not throw exceptions. When exceptions are enabled and the MGError code is set to a non-zero value, Autodesk MapGuide throws an exception. Depending on your development environment, the exception will halt your code and send an error message containing the line number of the error to the screen. 48 | Chapter 3 Accessing Maps