I am currently using java and spring boot to get authorized in a API. It depends on the value that users inserts to see weather the api is valid or not.If it's valid it would basically display data.
Main Problem
When user enters wrong value in the end of the api. I get error 500 "internal server error" and it stops my spring application. I want to create an exception where it would catch this error and spits out that there's an error 500 rather than stopping my application. Even with wrong value I want my application to continue running.
Error
When users enter the wrong params I receive an error below
org.springframework.web.client.HttpServerErrorException: 500 Internal Server Error
How can I override it, so that even if user enter wrong data, Don't break my application and continue running. Just display Null for data.
Attempt to handle
I was able to allow my application to continue running with following code below
try { //OauthRestTemplate exhanges credentials for api access } catch (HttpServerErrorException e ) { e.getStatusCode(); logger.info(e +"Server bypass, Continue running application"); //allow application to continue running but does not display the actual message that would be on the api. } //output org.springframework.web.client.HttpServerErrorException: 500 Internal Server ErrorServer bypass, Continue running application
But I want it to by pass the status 500 and display the actual message when I am on the api with wrong parameters. I should receive the same values that are printed on the api. Example Below
{"message":"Physical resource does not exist for mac address: D","code":"APRO-2001","timestamp":1490895756655,"type":"com.server.camp.framework.exception.ErrorResponse","status":"INTERNAL_SERVER_ERROR"}