(
code: keyof typeof this.errors,
detail?: string,
status?: number,
otherFields: Record<string, any> = {},
)
| 2643 | } |
| 2644 | |
| 2645 | private makeError( |
| 2646 | code: keyof typeof this.errors, |
| 2647 | detail?: string, |
| 2648 | status?: number, |
| 2649 | otherFields: Record<string, any> = {}, |
| 2650 | ) { |
| 2651 | status = status ?? this.errors[code]?.status ?? 500; |
| 2652 | const error: any = { |
| 2653 | status, |
| 2654 | code: paramCase(code), |
| 2655 | title: this.errors[code]?.title, |
| 2656 | }; |
| 2657 | |
| 2658 | if (detail) { |
| 2659 | error.detail = detail; |
| 2660 | } |
| 2661 | |
| 2662 | Object.assign(error, otherFields); |
| 2663 | |
| 2664 | return { |
| 2665 | status, |
| 2666 | body: { |
| 2667 | errors: [error], |
| 2668 | }, |
| 2669 | }; |
| 2670 | } |
| 2671 | |
| 2672 | private makeUnsupportedModelError(model: string) { |
| 2673 | return this.makeError('unsupportedModel', `Model ${model} doesn't exist`); |
no test coverage detected