Skip to content

Commit

Permalink
Add @ExceptionHandler method for ApiSafeException
Browse files Browse the repository at this point in the history
  • Loading branch information
robleney-ardc committed Feb 8, 2023
1 parent 664692e commit 27c007c
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import raido.apisvc.exception.CrossAccountAccessException;
import raido.apisvc.exception.RaidApiException;
import raido.apisvc.exception.ResourceNotFoundException;
import raido.apisvc.exception.ValidationException;
import raido.apisvc.spring.RedactingExceptionResolver;
import raido.apisvc.spring.security.ApiSafeException;
import raido.idl.raidv2.model.FailureResponse;
import raido.idl.raidv2.model.ValidationFailureResponse;

Expand Down Expand Up @@ -68,4 +69,18 @@ public ResponseEntity<FailureResponse> handleRaidApiException(HttpServletRequest
.body(body);
}

/*
Added this to fix LegacyRaidV1MintTest. Can probably be deleted once new error handling is supported by the app.
*/
@ExceptionHandler(ApiSafeException.class)
public ResponseEntity<RedactingExceptionResolver.ErrorJson> handleApiSafeException(HttpServletRequest request, Exception e) {
final var errorJson = new RedactingExceptionResolver.ErrorJson();
errorJson.detail = ((ApiSafeException) e).getDetail();
errorJson.status = ((ApiSafeException) e).getHttpStatus();
errorJson.message = e.getMessage();

return ResponseEntity
.badRequest()
.body(errorJson);
}
}

0 comments on commit 27c007c

Please sign in to comment.