0
我使用ResourceDelegate處理GWTP靜態調度,並且希望捕獲客戶端REST請求中的所有異常。 我的REST後端回報:帶REST調度的GWT平臺:從異常處理程序中獲取http狀態代碼
- 401或403狀態碼,如果沒有授權/禁止
- 500其他 錯誤
所以,我加入通用處理器來RestDispatchAsyncModule:
new RestDispatchAsyncModule.Builder().exceptionHandler(MyRestExceptionHandler.class);
MyRestExceptionHandler.java:
public class MyRestExceptionHandler implements ExceptionHandler {
@Override
public Status onFailure(Throwable e) {
if (e instanceof ActionException){
ActionException a = (ActionException)e;
// How to get HTTP status code and response body here?
}
return null;
}
}
我發現所有的REST異常都是ActionException類的實例。 如何在MyRestExceptionHandler中獲取HTTP狀態碼和http響應正文?