http-status-messages.ts 502 B

12345678910111213141516171819
  1. export function getErrorMessageForStatusCode(statusCode?: number) {
  2. if (!statusCode) {
  3. return 'Unknown Error'
  4. }
  5. const statusCodes: { readonly [K: number]: string } = {
  6. 400: 'Bad Request',
  7. 401: 'Unauthorized',
  8. 403: 'Forbidden',
  9. 404: 'Not Found',
  10. 422: 'Unprocessable Entity',
  11. 429: 'Too Many Requests',
  12. 500: 'Internal Server Error',
  13. 502: 'Bad Gateway',
  14. 503: 'Service Unavailable',
  15. }
  16. return statusCodes[statusCode] ?? `Unexpected Error: ${statusCode}`
  17. }