From 8884a74625abcd3b48bfe75f45541de69193f4bc Mon Sep 17 00:00:00 2001 From: n-kawahito Date: Fri, 18 Sep 2026 12:46:14 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[ADD]=E3=82=A8=E3=83=A9=E3=83=BC=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E5=87=A6=E7=90=86=E3=82=92=E5=AE=9F=E8=A3=85=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ErrorController.java | 12 +++++++ src/main/resources/templates/error.html | 32 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/main/java/com/example/demo/app/presentation/controller/ErrorController.java create mode 100644 src/main/resources/templates/error.html diff --git a/src/main/java/com/example/demo/app/presentation/controller/ErrorController.java b/src/main/java/com/example/demo/app/presentation/controller/ErrorController.java new file mode 100644 index 0000000..973d396 --- /dev/null +++ b/src/main/java/com/example/demo/app/presentation/controller/ErrorController.java @@ -0,0 +1,12 @@ +package com.example.demo.app.presentation.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class ErrorController { + @GetMapping("/error") + public String showError() { + return "error"; + } +} diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html new file mode 100644 index 0000000..2bf0229 --- /dev/null +++ b/src/main/resources/templates/error.html @@ -0,0 +1,32 @@ + + + + +エラー + + + + + + + +
+
+ +
+ +

+ エラーが発生しました +

+ +

+ + + ログイン画面へ + + +
+ + + + \ No newline at end of file From 7719c002ff85a81761acb35f8a593f1a4003e193 Mon Sep 17 00:00:00 2001 From: n-kawahito Date: Fri, 18 Sep 2026 12:46:43 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[ADD]=E5=85=B1=E9=80=9A=E4=BE=8B=E5=A4=96?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E5=AE=9F=E8=A3=85=E3=81=97=E3=81=BE?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/GlobalExceptionHandler.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/java/com/example/demo/exception/GlobalExceptionHandler.java diff --git a/src/main/java/com/example/demo/exception/GlobalExceptionHandler.java b/src/main/java/com/example/demo/exception/GlobalExceptionHandler.java new file mode 100644 index 0000000..17c1c7f --- /dev/null +++ b/src/main/java/com/example/demo/exception/GlobalExceptionHandler.java @@ -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"; + } +}