* Serve an error response.
(error: Error)
| 438 | * Serve an error response. |
| 439 | */ |
| 440 | function serveErrorResponse(error: Error) { |
| 441 | if (error instanceof DataFetcherError) { |
| 442 | return new Response(error.message, { |
| 443 | status: error.code, |
| 444 | headers: { 'content-type': 'text/plain' }, |
| 445 | }); |
| 446 | } |
| 447 | |
| 448 | throw error; |
| 449 | } |
| 450 | |
| 451 | /** |
| 452 | * Server a response with an API token obtained from the query params. |