Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Spring: Microservices with Spring Boot

You're reading from   Spring: Microservices with Spring Boot Build and deploy microservices with Spring Boot

Arrow left icon
Product type Paperback
Published in Mar 2018
Publisher
ISBN-13 9781789132588
Length 140 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
In28Minutes Official In28Minutes Official
Author Profile Icon In28Minutes Official
In28Minutes Official
Arrow right icon
View More author details
Toc

Exception Handling

Exception handling is one of the important parts of developing web services. When something goes wrong, we would want to return a good description of what went wrong to the service consumer. You would not want the service to crash without returning anything useful to the service consumer.

Spring Boot provides good default exception handling. We will start with looking at the default exception handling features provided by Spring Boot before moving on to customizing them.

Spring Boot Default Exception Handling

To understand the default exception handling provided by Spring Boot, let's start with firing a request to a nonexistent URL.

Non-Existent Resource

Let's send a GET request to http://localhost:8080/non-existing-resource using a header (Content-Type:application/json).

The following screenshot shows the response when we execute the request:

Non-Existent Resource

The response is as shown in the following code snippet:

    {
      "timestamp": 1484027734491,
      "status...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image