Skip to content

Commit

Permalink
Skip formatting errors in backend error scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
imesh94 committed Nov 14, 2024
1 parent 3b124d3 commit f8afe23
Show file tree
Hide file tree
Showing 2 changed files with 9 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,8 @@ 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 f8afe23

Please sign in to comment.