Skip to content

Commit

Permalink
Added ExceptionHandler for pipelineException
Browse files Browse the repository at this point in the history
  • Loading branch information
emanipravallika committed Oct 15, 2024
1 parent c0fd89b commit a1a606b
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,17 @@ class RetrofitErrorHandler {

static final Gson gson = new Gson()

@ExceptionHandler([RetrofitError.class])
@ExceptionHandler([RetrofitError.class, PipelineController.PipelineException.class])
@ResponseBody ResponseEntity<Object> handleRetrofitError(RetrofitError retrofitError){
if (retrofitError!=null){
log.warn("Exception occurred in OES downstream services : {}", retrofitError.getMessage())
log.warn("Exception occurred in OES downstream services : {}", retrofitError.getBody())
if (retrofitError.getKind() == RetrofitError.Kind.NETWORK){
log.warn("Retrofit Exception occurred of kind NETwork : {}", retrofitError.getBody())
ErrorResponseModel networkErrorResponse = populateNetworkErrorResponse(retrofitError)
return new ResponseEntity<Object>(networkErrorResponse, HttpStatus.INTERNAL_SERVER_ERROR)
}
if (retrofitError.getResponse()!=null && retrofitError.getResponse().getStatus() > 0){
log.warn("Exception occurred in : {}", retrofitError.getBody())
if (retrofitError.getResponse().getBody() !=null){
InputStream inputStream = null
try {
Expand All @@ -72,7 +74,7 @@ class RetrofitErrorHandler {
return new ResponseEntity<Object>(defaultErrorResponse, HttpStatus.INTERNAL_SERVER_ERROR)
}

@ExceptionHandler(PipelineController.PipelineException)
/*@ExceptionHandler(PipelineController.PipelineException)
@ResponseBody
ResponseEntity<Map<String, Object>> handlePipelineException(PipelineController.PipelineException ex) {
Map<String, Object> response = new HashMap<>();
Expand All @@ -87,7 +89,7 @@ class RetrofitErrorHandler {
log.error("PipelineException occurred: {}", ex.getMessage(), ex);
return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
}
}*/


private ErrorResponseModel populateDefaultErrorResponseModel() {
Expand Down

0 comments on commit a1a606b

Please sign in to comment.