Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip formatting errors in backend error scenarios #46

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading