Skip to content

Commit

Permalink
Merge pull request #46 from imesh94/fix/skip-backend-errors
Browse files Browse the repository at this point in the history
Skip formatting errors in backend error scenarios
  • Loading branch information
Akila94 authored Nov 14, 2024
2 parents a27fa79 + d55f287 commit 58b89e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public boolean mediate(MessageContext messageContext) {

// Error handling logic.
JSONObject errorData;
String statusCodeString = extractStatusCode(messageContext);
int statusCode = Integer.parseInt(statusCodeString);

if ((messageContext.getProperty(GatewayConstants.ERROR_CODE)) != null) {

int errorCode = (int) messageContext.getProperty(GatewayConstants.ERROR_CODE);
Expand Down Expand Up @@ -109,12 +112,14 @@ public boolean mediate(MessageContext messageContext) {
// Assume the errors thrown from the relevant internal webapps of these APIs are
// already formatted according to the CDS format
return true;
} else if (messageContext.getProperty(GatewayConstants.ENDPOINT_ADDRESS) != null &&
statusCode != HttpStatus.SC_REQUEST_TIMEOUT) {
// Assume the errors coming from the backend are properly formatted.
return true;
} else {
String statusCodeString = extractStatusCode(messageContext);
if (StringUtils.isBlank(statusCodeString)) {
return true;
}
int statusCode = Integer.parseInt(statusCodeString);
ErrorConstants.AUErrorEnum errorEnum;
if ("406".equals(statusCodeString)) {
errorEnum = ErrorConstants.AUErrorEnum.INVALID_ACCEPT_HEADER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ private GatewayConstants() {
public static final String REST_METHOD = "REST_METHOD";
public static final String OAUTH_JWT_ASSERTION = "client_assertion";
public static final String CLIENT_ID = "client_id";
public static final String ENDPOINT_ADDRESS = "ENDPOINT_ADDRESS";

// Constants related to executors
public static final String HTTP_GET = "GET";
Expand Down

0 comments on commit 58b89e1

Please sign in to comment.