( code: string, message: string, status: number, details?: unknown )
| 35 | * Create an error response |
| 36 | */ |
| 37 | export function errorResponse( |
| 38 | code: string, |
| 39 | message: string, |
| 40 | status: number, |
| 41 | details?: unknown |
| 42 | ): NextResponse<AdminErrorResponse> { |
| 43 | const body: AdminErrorResponse = { |
| 44 | error: { code, message }, |
| 45 | } |
| 46 | |
| 47 | if (details !== undefined) { |
| 48 | body.error.details = details |
| 49 | } |
| 50 | |
| 51 | return NextResponse.json(body, { status }) |
| 52 | } |
| 53 | |
| 54 | // ============================================================================= |
| 55 | // Common Error Responses |
no outgoing calls
no test coverage detected