import Err, { PAYLOAD } from "./mod.ts";
(async function example_without_err([foo, bar] = ["hello", "world"]) { try { let err = new Error("I just ran into a problem.");
function some_shitty_middleware(err: Error) { err.payload = { status: 500., }; }
err.payload = { foo, bar }; some_shitty_middleware(err);
throw err; } catch (err) { if (err.hasOwnProperty(PAYLOAD)) { console.error("I found this payload.", (err as Err).payload); } }})();
(async function example_with_err([foo, bar] = ["hello", "world"]) { try { throw new Err("I just ran into a problem.").with({ foo, bar }); } catch (err) { if (err.hasOwnProperty(PAYLOAD)) { console.error("I found this payload.", (err as Err).payload); } }})();