[Developer] #424 show DB setup errors

Refs #424
This commit is contained in:
devmrko
2026-06-23 11:12:07 +09:00
parent 7b45b3a028
commit fe8baa4d6a
4 changed files with 41 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
package com.cloudhandson.vpdbackoffice.web;
import com.cloudhandson.vpdbackoffice.service.AppException;
import org.springframework.dao.DataAccessException;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
@@ -13,4 +14,16 @@ public class AppExceptionHandler {
model.addAttribute("errorMessage", exception.getMessage());
return "error";
}
@ExceptionHandler(DataAccessException.class)
public String handleDataAccessException(DataAccessException exception, Model model) {
String detail = exception.getMostSpecificCause() == null
? exception.getMessage()
: exception.getMostSpecificCause().getMessage();
model.addAttribute("errorTitle", "ADB 연결 설정이 필요합니다.");
model.addAttribute("errorMessage",
"BACKOFFICE_DB_URL, BACKOFFICE_DB_USERNAME, BACKOFFICE_DB_PASSWORD를 실제 ADB 값으로 설정하고 "
+ "./run.sh backoffice-support를 실행한 뒤 다시 시도하세요. 상세: " + detail);
return "error";
}
}

View File

@@ -3,6 +3,8 @@ package com.cloudhandson.vpdbackoffice.web;
import com.cloudhandson.vpdbackoffice.service.BearerTokenService;
import com.cloudhandson.vpdbackoffice.service.PermissionService;
import com.cloudhandson.vpdbackoffice.service.ProtectedObjectService;
import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@@ -26,9 +28,23 @@ public class DashboardController {
@GetMapping("/")
public String dashboard(Model model) {
model.addAttribute("objects", protectedObjectService.findEnabled());
model.addAttribute("roles", permissionService.findRoles());
model.addAttribute("tokens", bearerTokenService.findAll());
try {
model.addAttribute("objects", protectedObjectService.findEnabled());
model.addAttribute("roles", permissionService.findRoles());
model.addAttribute("tokens", bearerTokenService.findAll());
} catch (DataAccessException e) {
model.addAttribute("objects", List.of());
model.addAttribute("roles", List.of());
model.addAttribute("tokens", List.of());
model.addAttribute("setupError", dbSetupMessage(e));
}
return "dashboard";
}
private String dbSetupMessage(DataAccessException e) {
String detail = e.getMostSpecificCause() == null ? e.getMessage() : e.getMostSpecificCause().getMessage();
return "ADB 연결을 확인할 수 없습니다. BACKOFFICE_DB_URL, BACKOFFICE_DB_USERNAME, "
+ "BACKOFFICE_DB_PASSWORD를 설정하고 ./run.sh backoffice-support를 먼저 실행하세요. 상세: "
+ detail;
}
}

View File

@@ -9,6 +9,14 @@
<p>보호 객체, Bearer Token, ORDS 검증 상태를 확인합니다.</p>
</div>
<div class="alert alert-warning" th:if="${setupError}">
<div class="fw-semibold">DB 연결 설정이 필요합니다.</div>
<div th:text="${setupError}"></div>
<div class="mt-2">
<code>./run.sh backoffice-support</code>
</div>
</div>
<section class="summary-grid">
<a class="summary-tile" href="/permissions">
<span class="label">보호 객체</span>

View File

@@ -5,7 +5,7 @@
<nav th:replace="~{fragments/layout :: nav}"></nav>
<main class="container py-4">
<div class="alert alert-danger">
<strong>처리할 수 없습니다.</strong>
<strong th:text="${errorTitle} ?: '처리할 수 없습니다.'">처리할 수 없습니다.</strong>
<span th:text="${errorMessage} ?: '요청 처리 중 오류가 발생했습니다.'"></span>
</div>
<a class="btn btn-outline-primary" href="/">대시보드</a>