[ADD]共通例外処理を実装しました
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
package com.example.demo.exception;
|
||||||
|
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
|
||||||
|
@ControllerAdvice
|
||||||
|
public class GlobalExceptionHandler {
|
||||||
|
|
||||||
|
@ExceptionHandler(Exception.class)
|
||||||
|
public String handleException(
|
||||||
|
Exception e,
|
||||||
|
Model model) {
|
||||||
|
|
||||||
|
model.addAttribute(
|
||||||
|
"errorMessage",
|
||||||
|
"システムエラーが発生しました。"
|
||||||
|
+ "初めからやり直してください。");
|
||||||
|
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user