| 31 | } |
| 32 | |
| 33 | private static makeMessage( |
| 34 | status: number | undefined, |
| 35 | error: any, |
| 36 | message: string | undefined, |
| 37 | ): string { |
| 38 | const msg = error?.message |
| 39 | ? typeof error.message === 'string' |
| 40 | ? error.message |
| 41 | : JSON.stringify(error.message) |
| 42 | : error |
| 43 | ? JSON.stringify(error) |
| 44 | : message; |
| 45 | |
| 46 | if (status && msg) { |
| 47 | return `${status} ${msg}`; |
| 48 | } |
| 49 | if (status) { |
| 50 | return `${status} status code (no body)`; |
| 51 | } |
| 52 | if (msg) { |
| 53 | return msg; |
| 54 | } |
| 55 | return '(no status code or body)'; |
| 56 | } |
| 57 | |
| 58 | static generate( |
| 59 | status: number | undefined, |