例外ハンドラ(ExceptionHandler)を拡張し、struts-config.xmlに設定を追加するのが良いと思います。
また、一度全ての例外ハンドリング箇所をチェックし、もし例外を握りつぶしているような箇所があれば非チェック例外でラップするようにしたほうがいいでしょう。
イメージは以下のような感じです。
◆例外ハンドラ(ExceptionHandler)を拡張
public class CustomizeExceptionHandler extends ExceptionHandler {
static Logger logger = Logger.getLogger(CustomizeExceptionHandler.class);
public ActionForward execute(Exception ex, ExceptionConfig ae, ActionMapping mapping, ActionForm formInstance, HttpServletRequest request, HttpServletResponse response) throws ServletException {
//ここに例外に関する処理を追加。
//logger.error("例外発生: " + ex.getMessage());
return super.execute(ex, ae, mapping, formInstance, request, response);
}
}
◆struts-config.xmlに拡張した例外ハンドラを追加
<global-exceptions>
<exception
key="error.Exception"
type="java.lang.Throwable"
handler="examples.exceptions.CustomizeExceptionHandler" />
</global-exceptions>
◆例外を握りつぶしていたら非チェック例外でラップする
} catch (Exception e) {
//何も処理なし
}
↓変更
} catch (Exception e) {
throw new RuntimeException(e);
}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。