views:

41

answers:

1

I'm trying to capture and handle the return of a NullPointerException in my DWR method call:

CompaniesByCountyFactory.getElementCompanies(command, countyId, stateId, {
callback:popupDisplay,
errorHandler:function(message){jQuery("<span>errorHandler::"+message+"</span>").dialog();},
exceptionHandler:function(errorString, exception){jQuery("
<span>exceptionHandler::"+errorString+"</span>").dialog();}
 });

Now the code path I'm testing causes getElementCompanies to throw a null pointer exception. This method is only called by DWR and is how I'm trying to communicate that the user must be logged out.

The problem stands in that neither my errorHandler or my exceptionHandler are ever being called.

DWR seems to see the exception and then automatically issue an alert() of the exception error string and I cannot figure out how to override this behavior.

Any ideas what I'm doing wrong?

Thanks

+1  A: 

I don't see anything glaringly wrong with this, assuming you're using DWR 2.0+.

If you're using DWR 1, you'll need to use:

dwr.engine.setErrorHandler(handler);

I tried your code, just made the callbacks simpler without using jQuery, and it works fine here (using DWR 2.0.5).

I'm sure you've already seen it, but if not:

http://directwebremoting.org/dwr/other/errors.html

desau