I am setting up new microservice api to connect and grab information from 3rd party REST api. This is the api more like internal for our services so other api's can consume this one.
I have an internal microservice design like this:
Controller -> (calls) -> Service Layer -> (calls) -> Service Implementation -> (calls) -> rest 3rd party API
Error Handling as below, when there is any issue/exception i fill all ErrorDetailsObj
in exception handler(@ControllerAdvice)
and return the response entity wrapper to the consuming services.
public class ErrorObject {
private String code;
private String message; //(i choose message from error.prop based on the code)
}
public class ErrorDetailsObj {
private HttpStatus httpStatus;
private LocalDateTime timestamp;
private String message;
private List<ErrorObject> errors;
}
- Am I doing the right design? Or is there any better way to simplify the error handling?
- Do I need to send only error code, so that consuming services can choose the right error message and display? in my case this is my own internal service which connects to 3rd party service.
- Any best example's for error handling?