(code: string)
| 4 | export type NormalizedHttpError = ReturnType<typeof normalizeError>; |
| 5 | |
| 6 | export function statusCodeForNormalizedError(code: string): number { |
| 7 | switch (code) { |
| 8 | case 'INVALID_ARGS': |
| 9 | return 400; |
| 10 | case 'UNAUTHORIZED': |
| 11 | return 401; |
| 12 | case 'SESSION_NOT_FOUND': |
| 13 | return 404; |
| 14 | default: |
| 15 | return 500; |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | export function sendRestJsonError(res: http.ServerResponse, normalized: NormalizedHttpError): void { |
| 20 | res.statusCode = statusCodeForNormalizedError(normalized.code); |
no outgoing calls
no test coverage detected