The exception handling is different for Synchronous Callback and for Asynchronous Callback.
For Synchronous Callback we can use
try catch blocks for error handling:
try{
alert(ob_post.post(null, "onEvent"));
}
catch(ex){
switch (ex.type){
// based on the exceptionType do specific instructions
case ...
}
}
When an Exception is thrown for Asynchronous Callback, the function that is executed after the callback is done will receive
null as the first argument and the Exception name as the second argument.
In the client side function we should first test that if any exceptions occured and continue with the proper code.
function myFunction(result, ex){
if (ex != null){ // equivalent to if (result == null){
switch (ex.type){
// based on the exceptionType do specific instructions
case ...
}
}
else{
// if there was no exception
}
}
Please visit the debugging examples for
synchronous and
asynchronous callback.