libmodulor
Version:
A TypeScript library to create platform-agnostic applications
75 lines (74 loc) • 3.45 kB
JavaScript
import { status } from '@grpc/grpc-js';
export const MAPPING = new Map([
// 1xx Informational
[], // Continue
[], // Switching Protocols
[], // Processing
[], // Early Hints
// 2xx Success
[], // OK
[], // Created
[], // Accepted
[], // Non-Authoritative Information
[], // No Content
[], // Reset Content
[], // Partial Content
[], // Multi-Status
[], // Already Reported
[], // IM Used
// 3xx Redirection
[], // Multiple Choices
[], // Moved Permanently
[], // Found
[], // See Other
[], // Not Modified
[], // Use Proxy
[], // Temporary Redirect
[], // Permanent Redirect
// 4xx Client errors
[], // Bad Request
[], // Unauthorized
[], // Payment Required
[], // Forbidden
[], // Not Found
[], // Method Not Allowed
[], // Not Acceptable
[], // Proxy Authentication Required
[], // Request Timeout
[], // Conflict
[], // Gone
[], // Length Required
[], // Precondition Failed
[], // Payload Too Large
[], // URI Too Long
[], // Unsupported Media Type
[], // Range Not Satisfiable
[], // Expectation Failed
[], // I'm a teapot
[], // Misdirected Request
[], // Unprocessable Entity
[], // Locked
[], // Failed Dependency
[], // Too Early
[], // Upgrade Required
[], // Precondition Required
[], // Too Many Requests
[], // Request Header Fields Too Large
[], // Unavailable For Legal Reasons
[], // Client Closed Request
// 5xx Server errors
[], // Internal Server Error
[], // Not Implemented
[], // Bad Gateway
[], // Service Unavailable
[], // Gateway Timeout
[], // HTTP Version Not Supported
[], // Variant Also Negotiates
[], // Insufficient Storage
[], // Loop Detected
[], // Not Extended
[], // Network Authentication Required
]);
export function errToStatus(err) {
return MAPPING.get(err.httpStatus) ?? status.UNKNOWN;
}