48
|
Chapter 3
Accessing Maps
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.
Summary of Contents for 15606-011408-9300 - MAP R6.3 UPG
Page 1: ...15306 010000 5060 October 2001 Autodesk MapGuide Release 6 Developer s Guide ...
Page 6: ...vi ...
Page 16: ...16 ...
Page 30: ...30 ...
Page 84: ...84 ...
Page 134: ...134 ...
Page 202: ...202 ...