Function
apiError
(route: string, message: string, status = 500, err?: unknown)
Source from the content-addressed store, hash-verified
| 5 | * All API routes should use this for consistent error handling. |
| 6 | */ |
| 7 | export function apiError(route: string, message: string, status = 500, err?: unknown) { |
| 8 | if (err) { |
| 9 | console.error(`[api/${route}] ${message}:`, err); |
| 10 | } else { |
| 11 | console.error(`[api/${route}] ${message}`); |
| 12 | } |
| 13 | return NextResponse.json({ error: message }, { status }); |
| 14 | } |
Tested by
no test coverage detected