Error handler for fetch responses, e.g. Cloudflare Workers.
npm install @borderless/fetch-error-handler --save
import { compose } from "throwback";
import { errorHandler } from "@borderless/fetch-error-handler";
import { finalHandler } from "@borderless/fetch-final-handler";
const app = compose([get(), post()]);
const req = new Request("/");
const res = await app(req, finalHandler()).catch(
errorHandler(req, { production: true })
);
This project is written using TypeScript and publishes the definitions directly to NPM.
MIT