[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;
}
}