私は自分のカスタム例外を実装しました。私はフレームワークコンソールに例外を表示したくありません。出来ますか?コンソールで例外を印刷しない方法
2017年5月15日2:47:24 PM org.apache.catalina.core.StandardWrapperValve SEVERE 呼び出す:サーブレット[プロジェクト - サービス]のためのServlet.service()を経路に関連して[/プロジェクトサービス] throw th exception [リクエスト処理に失敗しました。入れ子になった例外はba.project.exception.TAExceptionです:選択した日付の間にツアーアクティビティはありません。]根本的な原因 ba.project.exception.TAException:選択されたdates.at ba.project.serviceの間にツアーアクティビティはありません.TAServices.findByTourTypeWithDates(TAServices.java:94)
カスタム例外:ここ
public class TAException extends RuntimeException {
private static final long serialVersionUID = 1 L;
public TAException(String msg) {
super(msg);
}
public TAException(String msg, Throwable e) {
super(msg, e);
}
}
が、私は例外をスローする方法である:
public List <Object> findByTourTypeWithDates(String tourType, Date checkin, Date checkout)
throws ParseException, TAException {
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
Date todayDate = dateFormatter.parse(dateFormatter.format(new Date()));
if (checkin.after(todayDate)) {
return taDAO.findByTourTypeWithDates(tourType, checkin, checkout);
}
throw new TAException("There is no any tour activity between selected dates.");
}
あなたは何を期待しましたか?キャッチされていない例外をスローすると、それが印刷されます。 – Henry
フロントエンドに例外メッセージをカスタムメッセージで表示したかっただけです – Eniss
http://stackoverflow.com/questions/18849415/how-to-stop-printing-exception-stack-trace-on-console – zero01alpha