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