(error: any, req: any, res: any, _: any)
| 2 | import { expireSessionCookies } from '@linen/auth-server/server'; |
| 3 | |
| 4 | export function onError(error: any, req: any, res: any, _: any) { |
| 5 | if (error.message === 'jwt expired') { |
| 6 | try { |
| 7 | expireSessionCookies({ req, res }); |
| 8 | } catch (error) {} |
| 9 | } |
| 10 | |
| 11 | error.status = error instanceof ZodError ? 400 : error.status || 500; |
| 12 | |
| 13 | const path = !!req.baseUrl ? req.baseUrl + req.path : req.url; |
| 14 | |
| 15 | console.error( |
| 16 | `[${req.method}] ${path} >> StatusCode:: ${error.status}, Message:: ${error.message}` |
| 17 | ); |
| 18 | |
| 19 | if (error.status === 500) { |
| 20 | error.message = 'Something went wrong'; |
| 21 | } |
| 22 | |
| 23 | res.status(error.status).json({ message: error.message }); |
| 24 | } |
| 25 | |
| 26 | export function onGetError(error: any, req: any, res: any, _: any) { |
| 27 | const path = !!req.baseUrl ? req.baseUrl : req.url; |
nothing calls this directly
no test coverage detected