MCPcopy
hub / github.com/sveltejs/kit / normalise_error_handler

Function normalise_error_handler

packages/kit/src/core/postbuild/prerender.js:60–76  ·  view source on GitHub ↗

* @template {{message: string}} T * @template {Omit } K * @param {import('types').Logger} log * @param {'fail' | 'warn' | 'ignore' | ((details: T) => void)} input * @param {(details: K) => string} format * @returns {(details: K) => void}

(log, input, format)

Source from the content-addressed store, hash-verified

58 * @returns {(details: K) => void}
59 */
60 function normalise_error_handler(log, input, format) {
61 switch (input) {
62 case 'fail':
63 return (details) => {
64 throw new Error(format(details));
65 };
66 case 'warn':
67 return (details) => {
68 log.error(format(details));
69 };
70 case 'ignore':
71 return () => {};
72 default:
73 // @ts-expect-error TS thinks T might be of a different kind, but it's not
74 return (details) => input({ ...details, message: format(details) });
75 }
76 }
77
78 const OK = 2;
79 const REDIRECT = 3;

Callers 1

prerenderFunction · 0.85

Calls 2

formatFunction · 0.85
errorMethod · 0.65

Tested by

no test coverage detected