Skip to content

Some Exceptions that you might encounter with Rest APIs

Notifications You must be signed in to change notification settings

alpha-mo/ApiExceptionHandeling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring boot REST API Exception Demo


About this Demo:

This Example allocates a simple Rest API that calls a fake service class. The purpose of this demo is to handle some bad API calls from the frontend and let the backend respond accordingly.

Exceptions handled in this demo:

  • Custom Exception ResourceNotFoundException:

can be used to throw an error when querying a resource in your DB.


  • MissingRequestHeaderException:

Self-explanatory: used when an argument in the request header is missing.


  • MethodArgumentTypeMismatchException:

Triggered when the argument in the request is in the wrong data-type.


  • NoHandlerFoundException

Triggered when the exception has no exception-handler, in this demo it was implemented as a trigger for calling an API address that does not exist.


The Demo utilizes the @ControllerAdvice to handle the API Exceptions.

Only Spring Web was used as a dependency.

About

Some Exceptions that you might encounter with Rest APIs

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages