Skip to content

Commit

Permalink
Gateway error handling: add a handler for 404 status code and fix the…
Browse files Browse the repository at this point in the history
… 400 status code message

Fixes rucio#313
  • Loading branch information
MytsV committed Aug 15, 2024
1 parent a03e562 commit c103314
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/lib/sdk/gateway-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,10 @@ async function handleCommonGatewayEndpointErrors<TDTO extends BaseDTO>(statusCod
errorMessage: `An error occurred while fetching ${response.url}`,
} as TDTO;


switch(statusCode) {
case 400:
dto.errorName = BaseHttpErrorTypes.NOT_FOUND.errorName;
dto.errorMessage = `The requested resource was not found at ${response.url}.`
dto.errorName = BaseHttpErrorTypes.BAD_REQUEST.errorName;
dto.errorMessage = `The request had invalid syntax.`
try {
const message = await response.json();
dto.errorMessage += ` Error Details: ${message}`;
Expand All @@ -286,6 +285,14 @@ async function handleCommonGatewayEndpointErrors<TDTO extends BaseDTO>(statusCod
dto.errorMessage += ` Error Details: ${message}`;
} catch(error) {}
break;
case 404:
dto.errorName = BaseHttpErrorTypes.NOT_FOUND.errorName;
dto.errorMessage = `The requested resource was not found at ${response.url}.`
try {
const message = await response.json();
dto.errorMessage += ` Error Details: ${message}`;
} catch(error) {}
break;
case 406:
dto.errorName = BaseHttpErrorTypes.NOT_ACCEPTABLE.errorName;
dto.errorMessage = `Not Acceptable.`;
Expand Down

0 comments on commit c103314

Please sign in to comment.