Bird
0
0

You wrote a custom exception handler to return Problem Details but the API returns a plain error message instead. What is the most likely cause?

medium📝 Debug Q14 of 15
Spring Boot - Exception Handling
You wrote a custom exception handler to return Problem Details but the API returns a plain error message instead. What is the most likely cause?
AThe exception class does not extend RuntimeException
BThe controller method is not annotated with @GetMapping
CThe application.properties file is missing
DThe handler method is missing @ExceptionHandler annotation
Step-by-Step Solution
Solution:
  1. Step 1: Check exception handler setup

    Custom handlers must use @ExceptionHandler to catch exceptions and format responses.
  2. Step 2: Identify missing annotation impact

    Without @ExceptionHandler, Spring Boot won't invoke the handler, so default error response is sent.
  3. Final Answer:

    The handler method is missing @ExceptionHandler annotation -> Option D
  4. Quick Check:

    @ExceptionHandler missing = no custom error [OK]
Quick Trick: Always add @ExceptionHandler to custom error methods [OK]
Common Mistakes:
  • Thinking controller mapping affects exception handling
  • Assuming properties file controls error format
  • Believing exception must extend RuntimeException

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes