* Return a Response with matching headers and body, but with * an error status code (i.e. 599) and %%message%% with an * optional %%error%%.
(message?: string, error?: Error)
| 871 | * optional %%error%%. |
| 872 | */ |
| 873 | makeServerError(message?: string, error?: Error): FetchResponse { |
| 874 | let statusMessage: string; |
| 875 | if (!message) { |
| 876 | message = `${ this.statusCode } ${ this.statusMessage }`; |
| 877 | statusMessage = `CLIENT ESCALATED SERVER ERROR (${ message })`; |
| 878 | } else { |
| 879 | statusMessage = `CLIENT ESCALATED SERVER ERROR (${ this.statusCode } ${ this.statusMessage }; ${ message })`; |
| 880 | } |
| 881 | const response = new FetchResponse(599, statusMessage, this.headers, |
| 882 | this.body, this.#request || undefined); |
| 883 | response.#error = { message, error }; |
| 884 | return response; |
| 885 | } |
| 886 | |
| 887 | /** |
| 888 | * If called within a [request.processFunc](FetchRequest-processFunc) |