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

Function getErrorFactory

benchmark/error/system-error-instantiation.js:17–36  ·  view source on GitHub ↗
(code)

Source from the content-addressed store, hash-verified

15});
16
17function getErrorFactory(code) {
18 const {
19 ERR_FS_CP_DIR_TO_NON_DIR,
20 } = require('internal/errors').codes;
21
22 switch (code) {
23 case 'built-in':
24 return (n) => new Error();
25 case 'ERR_FS_CP_DIR_TO_NON_DIR':
26 return (n) => new ERR_FS_CP_DIR_TO_NON_DIR({
27 message: 'cannot overwrite directory',
28 path: 'dest',
29 syscall: 'cp',
30 errno: 21,
31 code: 'EISDIR',
32 });
33 default:
34 throw new Error(`${code} not supported`);
35 }
36}
37
38function main({ n, code, stackTraceLimit }) {
39 const getError = getErrorFactory(code);

Callers 1

mainFunction · 0.70

Calls 1

requireFunction · 0.50

Tested by

no test coverage detected