2010-08-10 54 views
1

我試圖捕獲和處理一個NullPointerException在我的DWR方法調用的返回:DWR異常處理

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();} 
}); 

現在的代碼路徑,我測試導致getElementCompanies拋出一個空指針異常。此方法僅由DWR調用,並且是我如何通知用戶必須註銷。

問題在於,我的errorHandler或者我的exceptionHandler都不會被調用。

DWR似乎看到異常,然後自動發出異常錯誤字符串的alert(),我無法弄清楚如何覆蓋這種行爲。

任何想法我做錯了什麼?

感謝

+0

您使用DWR哪個版本的? – letronje 2010-08-17 19:20:09

回答

3

我看不出什麼錯得離譜這種情況,假設你使用DWR 2.0+。

如果您使用DWR 1,你需要使用:

dwr.engine.setErrorHandler(handler); 

我想你的代碼,只是做了簡單的回調不使用jQuery和在這裏工作正常(使用DWR 2.0。 5)。

我相信你已經看到過它,但如果沒有:

http://directwebremoting.org/dwr/documentation/browser/errors.html