MCPcopy Index your code
hub / github.com/nodejs/node / getErrorFactory

Function getErrorFactory

benchmark/error/node-error-instantiation.js:19–38  ·  view source on GitHub ↗
(code)

Source from the content-addressed store, hash-verified

17});
18
19function getErrorFactory(code) {
20 const {
21 ERR_HTTP2_STREAM_SELF_DEPENDENCY,
22 ERR_INVALID_STATE,
23 ERR_INVALID_URL,
24 } = require('internal/errors').codes;
25
26 switch (code) {
27 case 'built-in':
28 return (n) => new Error();
29 case 'ERR_HTTP2_STREAM_SELF_DEPENDENCY':
30 return (n) => new ERR_HTTP2_STREAM_SELF_DEPENDENCY();
31 case 'ERR_INVALID_STATE':
32 return (n) => new ERR_INVALID_STATE(n + '');
33 case 'ERR_INVALID_URL':
34 return (n) => new ERR_INVALID_URL({ input: n + '' });
35 default:
36 throw new Error(`${code} not supported`);
37 }
38}
39
40function main({ n, code, stackTraceLimit }) {
41 const getError = getErrorFactory(code);

Callers 1

mainFunction · 0.70

Calls 1

requireFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…