/
_errors.ts
2790 lines (2629 loc) · 68.4 KB
/
_errors.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright Node.js contributors. All rights reserved. MIT License.
/** ********** NOT IMPLEMENTED
* ERR_MANIFEST_ASSERT_INTEGRITY
* ERR_QUICSESSION_VERSION_NEGOTIATION
* ERR_REQUIRE_ESM
* ERR_TLS_CERT_ALTNAME_INVALID
* ERR_WORKER_INVALID_EXEC_ARGV
* ERR_WORKER_PATH
* ERR_QUIC_ERROR
* ERR_SOCKET_BUFFER_SIZE //System error, shouldn't ever happen inside Deno
* ERR_SYSTEM_ERROR //System error, shouldn't ever happen inside Deno
* ERR_TTY_INIT_FAILED //System error, shouldn't ever happen inside Deno
* ERR_INVALID_PACKAGE_CONFIG // package.json stuff, probably useless
* *********** */
import { getSystemErrorName, inspect } from "./util.ts";
import {
codeMap,
errorMap,
mapSysErrnoToUvErrno,
} from "./internal_binding/uv.ts";
import { assert } from "../_util/assert.ts";
import { fileURLToPath } from "./url.ts";
import { isWindows } from "../_util/os.ts";
import { os as osConstants } from "./internal_binding/constants.ts";
const {
errno: {
ENOTDIR,
ENOENT,
},
} = osConstants;
export { errorMap };
const kIsNodeError = Symbol("kIsNodeError");
/**
* @see https://github.com/nodejs/node/blob/f3eb224/lib/internal/errors.js
*/
const classRegExp = /^([A-Z][a-z0-9]*)+$/;
/**
* @see https://github.com/nodejs/node/blob/f3eb224/lib/internal/errors.js
* @description Sorted by a rough estimate on most frequently used entries.
*/
const kTypes = [
"string",
"function",
"number",
"object",
// Accept 'Function' and 'Object' as alternative to the lower cased version.
"Function",
"Object",
"boolean",
"bigint",
"symbol",
];
// Node uses an AbortError that isn't exactly the same as the DOMException
// to make usage of the error in userland and readable-stream easier.
// It is a regular error with `.code` and `.name`.
export class AbortError extends Error {
code: string;
constructor() {
super("The operation was aborted");
this.code = "ABORT_ERR";
this.name = "AbortError";
}
}
// deno-lint-ignore no-explicit-any
type GenericFunction = (...args: any[]) => any;
function addNumericalSeparator(val: string) {
let res = "";
let i = val.length;
const start = val[0] === "-" ? 1 : 0;
for (; i >= start + 4; i -= 3) {
res = `_${val.slice(i - 3, i)}${res}`;
}
return `${val.slice(0, i)}${res}`;
}
/** This function removes unnecessary frames from Node.js core errors. */
export function hideStackFrames<T extends GenericFunction = GenericFunction>(
fn: T,
): T {
// We rename the functions that will be hidden to cut off the stacktrace
// at the outermost one.
const hidden = "__node_internal_" + fn.name;
Object.defineProperty(fn, "name", { value: hidden });
return fn;
}
const captureLargerStackTrace = hideStackFrames(
function captureLargerStackTrace(err) {
// @ts-ignore this function is not available in lib.dom.d.ts
Error.captureStackTrace(err);
return err;
},
);
export interface ErrnoException extends Error {
errno?: number;
code?: string;
path?: string;
syscall?: string;
}
/**
* This creates an error compatible with errors produced in the C++
* This function should replace the deprecated
* `exceptionWithHostPort()` function.
*
* @param err A libuv error number
* @param syscall
* @param address
* @param port
* @return The error.
*/
export const uvExceptionWithHostPort = hideStackFrames(
function uvExceptionWithHostPort(
err: number,
syscall: string,
address?: string | null,
port?: number | null,
) {
const { 0: code, 1: uvmsg } = uvErrmapGet(err) || uvUnmappedError;
const message = `${syscall} ${code}: ${uvmsg}`;
let details = "";
if (port && port > 0) {
details = ` ${address}:${port}`;
} else if (address) {
details = ` ${address}`;
}
// deno-lint-ignore no-explicit-any
const ex: any = new Error(`${message}${details}`);
ex.code = code;
ex.errno = err;
ex.syscall = syscall;
ex.address = address;
if (port) {
ex.port = port;
}
return captureLargerStackTrace(ex);
},
);
/**
* This used to be `util._errnoException()`.
*
* @param err A libuv error number
* @param syscall
* @param original
* @return A `ErrnoException`
*/
export const errnoException = hideStackFrames(
function errnoException(err, syscall, original?): ErrnoException {
const code = getSystemErrorName(err);
const message = original
? `${syscall} ${code} ${original}`
: `${syscall} ${code}`;
// deno-lint-ignore no-explicit-any
const ex: any = new Error(message);
ex.errno = err;
ex.code = code;
ex.syscall = syscall;
return captureLargerStackTrace(ex);
},
);
function uvErrmapGet(name: number) {
return errorMap.get(name);
}
const uvUnmappedError = ["UNKNOWN", "unknown error"];
/**
* This creates an error compatible with errors produced in the C++
* function UVException using a context object with data assembled in C++.
* The goal is to migrate them to ERR_* errors later when compatibility is
* not a concern.
*
* @param ctx
* @return The error.
*/
export const uvException = hideStackFrames(function uvException(ctx) {
const { 0: code, 1: uvmsg } = uvErrmapGet(ctx.errno) || uvUnmappedError;
let message = `${code}: ${ctx.message || uvmsg}, ${ctx.syscall}`;
let path;
let dest;
if (ctx.path) {
path = ctx.path.toString();
message += ` '${path}'`;
}
if (ctx.dest) {
dest = ctx.dest.toString();
message += ` -> '${dest}'`;
}
// deno-lint-ignore no-explicit-any
const err: any = new Error(message);
for (const prop of Object.keys(ctx)) {
if (prop === "message" || prop === "path" || prop === "dest") {
continue;
}
err[prop] = ctx[prop];
}
err.code = code;
if (path) {
err.path = path;
}
if (dest) {
err.dest = dest;
}
return captureLargerStackTrace(err);
});
/**
* Deprecated, new function is `uvExceptionWithHostPort()`
* New function added the error description directly
* from C++. this method for backwards compatibility
* @param err A libuv error number
* @param syscall
* @param address
* @param port
* @param additional
*/
export const exceptionWithHostPort = hideStackFrames(
function exceptionWithHostPort(
err: number,
syscall: string,
address: string,
port: number,
additional?: string,
) {
const code = getSystemErrorName(err);
let details = "";
if (port && port > 0) {
details = ` ${address}:${port}`;
} else if (address) {
details = ` ${address}`;
}
if (additional) {
details += ` - Local (${additional})`;
}
// deno-lint-ignore no-explicit-any
const ex: any = new Error(`${syscall} ${code}${details}`);
ex.errno = err;
ex.code = code;
ex.syscall = syscall;
ex.address = address;
if (port) {
ex.port = port;
}
return captureLargerStackTrace(ex);
},
);
/**
* @param code A libuv error number or a c-ares error code
* @param syscall
* @param hostname
*/
export const dnsException = hideStackFrames(function (code, syscall, hostname) {
let errno;
// If `code` is of type number, it is a libuv error number, else it is a
// c-ares error code.
if (typeof code === "number") {
errno = code;
// ENOTFOUND is not a proper POSIX error, but this error has been in place
// long enough that it's not practical to remove it.
if (
code === codeMap.get("EAI_NODATA") ||
code === codeMap.get("EAI_NONAME")
) {
code = "ENOTFOUND"; // Fabricated error name.
} else {
code = getSystemErrorName(code);
}
}
const message = `${syscall} ${code}${hostname ? ` ${hostname}` : ""}`;
// deno-lint-ignore no-explicit-any
const ex: any = new Error(message);
ex.errno = errno;
ex.code = code;
ex.syscall = syscall;
if (hostname) {
ex.hostname = hostname;
}
return captureLargerStackTrace(ex);
});
/**
* All error instances in Node have additional methods and properties
* This export class is meant to be extended by these instances abstracting native JS error instances
*/
export class NodeErrorAbstraction extends Error {
code: string;
constructor(name: string, code: string, message: string) {
super(message);
this.code = code;
this.name = name;
//This number changes depending on the name of this class
//20 characters as of now
this.stack = this.stack && `${name} [${this.code}]${this.stack.slice(20)}`;
}
toString() {
return `${this.name} [${this.code}]: ${this.message}`;
}
}
export class NodeError extends NodeErrorAbstraction {
constructor(code: string, message: string) {
super(Error.prototype.name, code, message);
}
}
export class NodeSyntaxError extends NodeErrorAbstraction
implements SyntaxError {
constructor(code: string, message: string) {
super(SyntaxError.prototype.name, code, message);
Object.setPrototypeOf(this, SyntaxError.prototype);
this.toString = function () {
return `${this.name} [${this.code}]: ${this.message}`;
};
}
}
export class NodeRangeError extends NodeErrorAbstraction {
constructor(code: string, message: string) {
super(RangeError.prototype.name, code, message);
Object.setPrototypeOf(this, RangeError.prototype);
this.toString = function () {
return `${this.name} [${this.code}]: ${this.message}`;
};
}
}
export class NodeTypeError extends NodeErrorAbstraction implements TypeError {
constructor(code: string, message: string) {
super(TypeError.prototype.name, code, message);
Object.setPrototypeOf(this, TypeError.prototype);
this.toString = function () {
return `${this.name} [${this.code}]: ${this.message}`;
};
}
}
export class NodeURIError extends NodeErrorAbstraction implements URIError {
constructor(code: string, message: string) {
super(URIError.prototype.name, code, message);
Object.setPrototypeOf(this, URIError.prototype);
this.toString = function () {
return `${this.name} [${this.code}]: ${this.message}`;
};
}
}
interface NodeSystemErrorCtx {
code: string;
syscall: string;
message: string;
errno: number;
path?: string;
dest?: string;
}
// A specialized Error that includes an additional info property with
// additional information about the error condition.
// It has the properties present in a UVException but with a custom error
// message followed by the uv error code and uv error message.
// It also has its own error code with the original uv error context put into
// `err.info`.
// The context passed into this error must have .code, .syscall and .message,
// and may have .path and .dest.
class NodeSystemError extends NodeErrorAbstraction {
constructor(key: string, context: NodeSystemErrorCtx, msgPrefix: string) {
let message = `${msgPrefix}: ${context.syscall} returned ` +
`${context.code} (${context.message})`;
if (context.path !== undefined) {
message += ` ${context.path}`;
}
if (context.dest !== undefined) {
message += ` => ${context.dest}`;
}
super("SystemError", key, message);
captureLargerStackTrace(this);
Object.defineProperties(this, {
[kIsNodeError]: {
value: true,
enumerable: false,
writable: false,
configurable: true,
},
info: {
value: context,
enumerable: true,
configurable: true,
writable: false,
},
errno: {
get() {
return context.errno;
},
set: (value) => {
context.errno = value;
},
enumerable: true,
configurable: true,
},
syscall: {
get() {
return context.syscall;
},
set: (value) => {
context.syscall = value;
},
enumerable: true,
configurable: true,
},
});
if (context.path !== undefined) {
Object.defineProperty(this, "path", {
get() {
return context.path;
},
set: (value) => {
context.path = value;
},
enumerable: true,
configurable: true,
});
}
if (context.dest !== undefined) {
Object.defineProperty(this, "dest", {
get() {
return context.dest;
},
set: (value) => {
context.dest = value;
},
enumerable: true,
configurable: true,
});
}
}
toString() {
return `${this.name} [${this.code}]: ${this.message}`;
}
}
function makeSystemErrorWithCode(key: string, msgPrfix: string) {
return class NodeError extends NodeSystemError {
constructor(ctx: NodeSystemErrorCtx) {
super(key, ctx, msgPrfix);
}
};
}
export const ERR_FS_EISDIR = makeSystemErrorWithCode(
"ERR_FS_EISDIR",
"Path is a directory",
);
function createInvalidArgType(
name: string,
expected: string | string[],
): string {
// https://github.com/nodejs/node/blob/f3eb224/lib/internal/errors.js#L1037-L1087
expected = Array.isArray(expected) ? expected : [expected];
let msg = "The ";
if (name.endsWith(" argument")) {
// For cases like 'first argument'
msg += `${name} `;
} else {
const type = name.includes(".") ? "property" : "argument";
msg += `"${name}" ${type} `;
}
msg += "must be ";
const types = [];
const instances = [];
const other = [];
for (const value of expected) {
if (kTypes.includes(value)) {
types.push(value.toLocaleLowerCase());
} else if (classRegExp.test(value)) {
instances.push(value);
} else {
other.push(value);
}
}
// Special handle `object` in case other instances are allowed to outline
// the differences between each other.
if (instances.length > 0) {
const pos = types.indexOf("object");
if (pos !== -1) {
types.splice(pos, 1);
instances.push("Object");
}
}
if (types.length > 0) {
if (types.length > 2) {
const last = types.pop();
msg += `one of type ${types.join(", ")}, or ${last}`;
} else if (types.length === 2) {
msg += `one of type ${types[0]} or ${types[1]}`;
} else {
msg += `of type ${types[0]}`;
}
if (instances.length > 0 || other.length > 0) {
msg += " or ";
}
}
if (instances.length > 0) {
if (instances.length > 2) {
const last = instances.pop();
msg += `an instance of ${instances.join(", ")}, or ${last}`;
} else {
msg += `an instance of ${instances[0]}`;
if (instances.length === 2) {
msg += ` or ${instances[1]}`;
}
}
if (other.length > 0) {
msg += " or ";
}
}
if (other.length > 0) {
if (other.length > 2) {
const last = other.pop();
msg += `one of ${other.join(", ")}, or ${last}`;
} else if (other.length === 2) {
msg += `one of ${other[0]} or ${other[1]}`;
} else {
if (other[0].toLowerCase() !== other[0]) {
msg += "an ";
}
msg += `${other[0]}`;
}
}
return msg;
}
export class ERR_INVALID_ARG_TYPE_RANGE extends NodeRangeError {
constructor(name: string, expected: string | string[], actual: unknown) {
const msg = createInvalidArgType(name, expected);
super(
"ERR_INVALID_ARG_TYPE",
`${msg}.${invalidArgTypeHelper(actual)}`,
);
}
}
export class ERR_INVALID_ARG_TYPE extends NodeTypeError {
constructor(name: string, expected: string | string[], actual: unknown) {
const msg = createInvalidArgType(name, expected);
super(
"ERR_INVALID_ARG_TYPE",
`${msg}.${invalidArgTypeHelper(actual)}`,
);
}
static RangeError = ERR_INVALID_ARG_TYPE_RANGE;
}
class ERR_INVALID_ARG_VALUE_RANGE extends NodeRangeError {
constructor(name: string, value: unknown, reason: string = "is invalid") {
const type = name.includes(".") ? "property" : "argument";
const inspected = inspect(value);
super(
"ERR_INVALID_ARG_VALUE",
`The ${type} '${name}' ${reason}. Received ${inspected}`,
);
}
}
export class ERR_INVALID_ARG_VALUE extends NodeTypeError {
constructor(name: string, value: unknown, reason: string = "is invalid") {
const type = name.includes(".") ? "property" : "argument";
const inspected = inspect(value);
super(
"ERR_INVALID_ARG_VALUE",
`The ${type} '${name}' ${reason}. Received ${inspected}`,
);
}
static RangeError = ERR_INVALID_ARG_VALUE_RANGE;
}
// A helper function to simplify checking for ERR_INVALID_ARG_TYPE output.
// deno-lint-ignore no-explicit-any
function invalidArgTypeHelper(input: any) {
if (input == null) {
return ` Received ${input}`;
}
if (typeof input === "function" && input.name) {
return ` Received function ${input.name}`;
}
if (typeof input === "object") {
if (input.constructor && input.constructor.name) {
return ` Received an instance of ${input.constructor.name}`;
}
return ` Received ${inspect(input, { depth: -1 })}`;
}
let inspected = inspect(input, { colors: false });
if (inspected.length > 25) {
inspected = `${inspected.slice(0, 25)}...`;
}
return ` Received type ${typeof input} (${inspected})`;
}
export class ERR_OUT_OF_RANGE extends RangeError {
code = "ERR_OUT_OF_RANGE";
constructor(
str: string,
range: string,
input: unknown,
replaceDefaultBoolean = false,
) {
assert(range, 'Missing "range" argument');
let msg = replaceDefaultBoolean
? str
: `The value of "${str}" is out of range.`;
let received;
if (Number.isInteger(input) && Math.abs(input as number) > 2 ** 32) {
received = addNumericalSeparator(String(input));
} else if (typeof input === "bigint") {
received = String(input);
if (input > 2n ** 32n || input < -(2n ** 32n)) {
received = addNumericalSeparator(received);
}
received += "n";
} else {
received = inspect(input);
}
msg += ` It must be ${range}. Received ${received}`;
super(msg);
const { name } = this;
// Add the error code to the name to include it in the stack trace.
this.name = `${name} [${this.code}]`;
// Access the stack to generate the error message including the error code from the name.
this.stack;
// Reset the name to the actual name.
this.name = name;
}
}
export class ERR_AMBIGUOUS_ARGUMENT extends NodeTypeError {
constructor(x: string, y: string) {
super("ERR_AMBIGUOUS_ARGUMENT", `The "${x}" argument is ambiguous. ${y}`);
}
}
export class ERR_ARG_NOT_ITERABLE extends NodeTypeError {
constructor(x: string) {
super("ERR_ARG_NOT_ITERABLE", `${x} must be iterable`);
}
}
export class ERR_ASSERTION extends NodeError {
constructor(x: string) {
super("ERR_ASSERTION", `${x}`);
}
}
export class ERR_ASYNC_CALLBACK extends NodeTypeError {
constructor(x: string) {
super("ERR_ASYNC_CALLBACK", `${x} must be a function`);
}
}
export class ERR_ASYNC_TYPE extends NodeTypeError {
constructor(x: string) {
super("ERR_ASYNC_TYPE", `Invalid name for async "type": ${x}`);
}
}
export class ERR_BROTLI_INVALID_PARAM extends NodeRangeError {
constructor(x: string) {
super("ERR_BROTLI_INVALID_PARAM", `${x} is not a valid Brotli parameter`);
}
}
export class ERR_BUFFER_OUT_OF_BOUNDS extends NodeRangeError {
constructor(name?: string) {
super(
"ERR_BUFFER_OUT_OF_BOUNDS",
name
? `"${name}" is outside of buffer bounds`
: "Attempt to access memory outside buffer bounds",
);
}
}
export class ERR_BUFFER_TOO_LARGE extends NodeRangeError {
constructor(x: string) {
super(
"ERR_BUFFER_TOO_LARGE",
`Cannot create a Buffer larger than ${x} bytes`,
);
}
}
export class ERR_CANNOT_WATCH_SIGINT extends NodeError {
constructor() {
super(
"ERR_CANNOT_WATCH_SIGINT",
"Cannot watch for SIGINT signals",
);
}
}
export class ERR_CHILD_CLOSED_BEFORE_REPLY extends NodeError {
constructor() {
super(
"ERR_CHILD_CLOSED_BEFORE_REPLY",
"Child closed before reply received",
);
}
}
export class ERR_CHILD_PROCESS_IPC_REQUIRED extends NodeError {
constructor(x: string) {
super(
"ERR_CHILD_PROCESS_IPC_REQUIRED",
`Forked processes must have an IPC channel, missing value 'ipc' in ${x}`,
);
}
}
export class ERR_CHILD_PROCESS_STDIO_MAXBUFFER extends NodeRangeError {
constructor(x: string) {
super(
"ERR_CHILD_PROCESS_STDIO_MAXBUFFER",
`${x} maxBuffer length exceeded`,
);
}
}
export class ERR_CONSOLE_WRITABLE_STREAM extends NodeTypeError {
constructor(x: string) {
super(
"ERR_CONSOLE_WRITABLE_STREAM",
`Console expects a writable stream instance for ${x}`,
);
}
}
export class ERR_CONTEXT_NOT_INITIALIZED extends NodeError {
constructor() {
super(
"ERR_CONTEXT_NOT_INITIALIZED",
"context used is not initialized",
);
}
}
export class ERR_CPU_USAGE extends NodeError {
constructor(x: string) {
super(
"ERR_CPU_USAGE",
`Unable to obtain cpu usage ${x}`,
);
}
}
export class ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED extends NodeError {
constructor() {
super(
"ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED",
"Custom engines not supported by this OpenSSL",
);
}
}
export class ERR_CRYPTO_ECDH_INVALID_FORMAT extends NodeTypeError {
constructor(x: string) {
super(
"ERR_CRYPTO_ECDH_INVALID_FORMAT",
`Invalid ECDH format: ${x}`,
);
}
}
export class ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY extends NodeError {
constructor() {
super(
"ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY",
"Public key is not valid for specified curve",
);
}
}
export class ERR_CRYPTO_ENGINE_UNKNOWN extends NodeError {
constructor(x: string) {
super(
"ERR_CRYPTO_ENGINE_UNKNOWN",
`Engine "${x}" was not found`,
);
}
}
export class ERR_CRYPTO_FIPS_FORCED extends NodeError {
constructor() {
super(
"ERR_CRYPTO_FIPS_FORCED",
"Cannot set FIPS mode, it was forced with --force-fips at startup.",
);
}
}
export class ERR_CRYPTO_FIPS_UNAVAILABLE extends NodeError {
constructor() {
super(
"ERR_CRYPTO_FIPS_UNAVAILABLE",
"Cannot set FIPS mode in a non-FIPS build.",
);
}
}
export class ERR_CRYPTO_HASH_FINALIZED extends NodeError {
constructor() {
super(
"ERR_CRYPTO_HASH_FINALIZED",
"Digest already called",
);
}
}
export class ERR_CRYPTO_HASH_UPDATE_FAILED extends NodeError {
constructor() {
super(
"ERR_CRYPTO_HASH_UPDATE_FAILED",
"Hash update failed",
);
}
}
export class ERR_CRYPTO_INCOMPATIBLE_KEY extends NodeError {
constructor(x: string, y: string) {
super(
"ERR_CRYPTO_INCOMPATIBLE_KEY",
`Incompatible ${x}: ${y}`,
);
}
}
export class ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS extends NodeError {
constructor(x: string, y: string) {
super(
"ERR_CRYPTO_INCOMPATIBLE_KEY_OPTIONS",
`The selected key encoding ${x} ${y}.`,
);
}
}
export class ERR_CRYPTO_INVALID_DIGEST extends NodeTypeError {
constructor(x: string) {
super(
"ERR_CRYPTO_INVALID_DIGEST",
`Invalid digest: ${x}`,
);
}
}
export class ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE extends NodeTypeError {
constructor(x: string, y: string) {
super(
"ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE",
`Invalid key object type ${x}, expected ${y}.`,
);
}
}
export class ERR_CRYPTO_INVALID_STATE extends NodeError {
constructor(x: string) {
super(
"ERR_CRYPTO_INVALID_STATE",
`Invalid state for operation ${x}`,
);
}
}
export class ERR_CRYPTO_PBKDF2_ERROR extends NodeError {
constructor() {
super(
"ERR_CRYPTO_PBKDF2_ERROR",
"PBKDF2 error",
);
}
}
export class ERR_CRYPTO_SCRYPT_INVALID_PARAMETER extends NodeError {
constructor() {
super(
"ERR_CRYPTO_SCRYPT_INVALID_PARAMETER",
"Invalid scrypt parameter",
);
}
}
export class ERR_CRYPTO_SCRYPT_NOT_SUPPORTED extends NodeError {
constructor() {
super(
"ERR_CRYPTO_SCRYPT_NOT_SUPPORTED",
"Scrypt algorithm not supported",
);
}
}
export class ERR_CRYPTO_SIGN_KEY_REQUIRED extends NodeError {
constructor() {
super(
"ERR_CRYPTO_SIGN_KEY_REQUIRED",
"No key provided to sign",
);
}
}
export class ERR_DIR_CLOSED extends NodeError {
constructor() {
super(
"ERR_DIR_CLOSED",
"Directory handle was closed",
);
}
}
export class ERR_DIR_CONCURRENT_OPERATION extends NodeError {
constructor() {
super(
"ERR_DIR_CONCURRENT_OPERATION",
"Cannot do synchronous work on directory handle with concurrent asynchronous operations",
);
}
}
export class ERR_DNS_SET_SERVERS_FAILED extends NodeError {
constructor(x: string, y: string) {
super(
"ERR_DNS_SET_SERVERS_FAILED",
`c-ares failed to set servers: "${x}" [${y}]`,
);
}
}
export class ERR_DOMAIN_CALLBACK_NOT_AVAILABLE extends NodeError {
constructor() {
super(
"ERR_DOMAIN_CALLBACK_NOT_AVAILABLE",