r/SpringBoot • • Feb 07 '26

Question Error responses for REST API

Do you implement RFC 9457 in your error responses? I saw that Spring provides an abstraction for this with ProblemDetail, it looks good but not many people are using it.

12 Upvotes

15 comments sorted by

View all comments

Show parent comment

1

u/j0k3r_dev Feb 08 '26

Exceptions are thrown to halt program flow, and are generally handled with a try/catch block to return a response. This is because sometimes things don't go as expected, or it could even be due to an external issue: a database crashes, there's no response, or the wait time is too long. An exception is always thrown so the programmer can work on it. If you leave the exception unattended, your program will stop, meaning you'll have to manually restart it. These are simply basic concepts of introductory programming; they are very important, regardless of the framework or language.