Error handling for Spring Boot APIs — @ControllerAdvice, structured error
84
75%
Does it follow best practices?
Impact
99%
1.76xAverage score across 5 eval scenarios
Passed
No known issues
{
"context": "Tests whether the agent proactively adds production-grade error handling when building a Spring Boot restaurant ordering API. The task describes CRUD and business logic but never mentions error handling, exception handlers, or error response format.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Global exception handler with @RestControllerAdvice",
"description": "A centralized exception handler class annotated with @RestControllerAdvice or @ControllerAdvice is defined, containing multiple @ExceptionHandler methods for different exception types",
"max_score": 15
},
{
"name": "Custom exception hierarchy",
"description": "Custom exception classes are defined for different error scenarios (not-found, validation, business rule violation, conflict) with HTTP status code mapping, rather than using generic exceptions",
"max_score": 12
},
{
"name": "Consistent structured error response format",
"description": "All error responses use the same object shape with a code and message field. Not a mix of String bodies, Map shapes, and different structures from different endpoints",
"max_score": 12
},
{
"name": "Validation error handler with field details",
"description": "MethodArgumentNotValidException is handled and returns field-level validation errors in a structured list, not just a generic 400",
"max_score": 12
},
{
"name": "No stack trace leaks",
"description": "Unexpected exceptions are caught by a generic Exception handler that returns a safe message. Stack traces, internal class names, and raw exception messages are never sent to clients",
"max_score": 12
},
{
"name": "Bean validation with @Valid",
"description": "@Valid is used on @RequestBody parameters and DTOs use Jakarta Validation annotations (@NotBlank, @Positive, @Min, @Max, @Pattern, etc.) for input validation",
"max_score": 10
},
{
"name": "Appropriate HTTP status codes",
"description": "Semantically correct status codes: 400 for validation, 404 for not-found menu item or order, 409 for duplicate menu item name, 422 for invalid status transition or business rule violation, 500 for unexpected errors",
"max_score": 10
},
{
"name": "Malformed request handling",
"description": "HttpMessageNotReadableException or similar is caught to return a clean error when the request body is malformed JSON rather than Spring's default error page",
"max_score": 7
},
{
"name": "CRUD endpoints functional",
"description": "Core menu and order endpoints are implemented and return appropriate success responses with correct status codes",
"max_score": 10
}
]
}