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

feat: adding more fault names to the sharedflow reference sample #763

Merged
merged 2 commits into from
Nov 20, 2024
Merged
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 @@ -35,27 +35,69 @@ function setFault(status, phrase, code, message, url) {
}

switch (context.getVariable("fault.name")) {
//400 Bad Request
case "ExceededContainerDepth":
case "ExceededObjectEntryCount":
case "ExceededArrayElementCount":
case "ExceededObjectEntryNameLength":
case "ExceededStringValueLength":
case "SourceUnavailable":
case "NonMessageVariable":
case "ExecutionFailed":
case "ThreatDetected":
setFault(400,"Bad Request","400.99","Bad Request");
break;

//401 Unauthorized
case "ApiKeyNotApproved":
case "CompanyStatusNotActive":
case "DeveloperStatusNotActive":
case "FailedToResolveAPIKey":
case "InvalidApiKey":
case "InvalidApiKeyForGivenResource":
case "InvalidAPICallAsNoApiProductMatchFound":
case "app_not_approved":
case "FailedToResolveAccessToken":
case "FailedToResolveToken":
case "FailedToResolveAuthorizationCode":
case "InvalidAccessToken":
case "access_token_expired":
case "invalid_access_token":
case "InvalidAccessToken":
setFault(
401,
"Unauthorized",
"401.99",
"Unauthorized - Token Invalid or Expired"
);
case "InvalidOperation":
setFault(401,"Unauthorized","401.99","Unauthorized - Token Invalid or Expired");
break;

//403 Forbidden
case "InsufficientScope":
setFault(403,"Forbidden","403.99","Forbidden");
break;

//429 Too Many Requests
case "SpikeArrestViolation":
case "InvalidMessageWeight":
case "ErrorLoadingProperties":
case "FailedToResolveSpikeArrestRate":
case "QuotaViolation":
case "InvalidQuotaInterval":
case "InvalidQuotaTimeUnit":
case "FailedToResolveQuotaIntervalReference":
case "FailedToResolveQuotaIntervalTimeUnitReference":
setFault(429,"Too Many Requests","429.99","Too Many Requests");
break;

case "ErrorResponseCode":
switch (context.getVariable("response.status.code")) {
case "400":
setFault(400, "Bad Request", "400.99", "Invalid Request");
break;
case "404":
setFault(404, "Resource Not Found", "404.99", "Resource Not Found");
break;
}
setFault(context.getVariable("error.status.code"),context.getVariable("error.status.phrase"),context.getVariable("error.status.code")+".99",context.getVariable("error.status.phrase"));
break;
// switch (context.getVariable("response.status.code")) {
// case "400":
// setFault(400, "Bad Request", "400.99", "Invalid Request");
// break;
// case "404":
// setFault(404, "Resource Not Found", "404.99", "Resource Not Found");
// break;
// }
}

if (!context.getVariable("custom.error.code")) {
if (context.getVariable("flow.error.code") == null || !context.getVariable("custom.error.code")) {
setFault(500, "Internal Server Error", "500.99", "Internal Server Error");
}
Loading