© Balaji Varanasi and Maxim Bartkov 2022
B. Varanasi, M. BartkovSpring RESThttps://doi.org/10.1007/978-1-4842-7477-4_5

5. Error Handling

Balaji Varanasi1   and Maxim Bartkov2
(1)
Salt Lake City, UT, USA
(2)
Kharkov, Ukraine
 
In this chapter we will discuss the following:
  • Handling errors in a REST API

  • Designing meaningful error responses

  • Validating API inputs

  • Externalizing error messages

Error handling is one of the most important yet somewhat overlooked topics for programmers. Although we develop software with good intent, things do go wrong, and we must be prepared to handle and communicate those errors gracefully. The communication aspect is especially important to developers consuming a REST API. Well-designed error responses allow consuming developers ...

Get Spring REST: Building Java Microservices and Cloud Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.