kerium 1.3.3 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/error.d.ts +1 -1
- package/dist/error.js +6 -11
- package/package.json +1 -1
package/dist/error.d.ts
CHANGED
|
@@ -454,7 +454,7 @@ export declare class Exception extends Error implements NodeJS.ErrnoException, E
|
|
|
454
454
|
export declare function UV(this: void, code: keyof typeof Errno, syscall: string, path?: string, dest?: string): Exception;
|
|
455
455
|
export declare function UV(this: void, code: keyof typeof Errno, context?: ExceptionExtra): Exception;
|
|
456
456
|
/**
|
|
457
|
-
* Shortcut to easily create an `
|
|
457
|
+
* Shortcut to easily create an `Exception` with a specific error code.
|
|
458
458
|
*/
|
|
459
459
|
export declare function withErrno(this: void, code: keyof typeof Errno, message?: string): Exception;
|
|
460
460
|
export declare function rethrow(syscall: string, path?: string, dest?: string): (e: Exception) => never;
|
package/dist/error.js
CHANGED
|
@@ -415,7 +415,7 @@ export function setUVMessage(ex) {
|
|
|
415
415
|
message += ` '${ex.path}'`;
|
|
416
416
|
if (ex.dest)
|
|
417
417
|
message += ` -> '${ex.dest}'`;
|
|
418
|
-
if (ex.message && ex.message
|
|
418
|
+
if (ex.message && !ex.message.startsWith(errnoMessages[ex.errno]))
|
|
419
419
|
message += ` (${ex.message})`;
|
|
420
420
|
ex.message = message;
|
|
421
421
|
return ex;
|
|
@@ -439,17 +439,12 @@ export class Exception extends Error {
|
|
|
439
439
|
syscall;
|
|
440
440
|
constructor(errno, message, ctx = {}) {
|
|
441
441
|
const code = Errno[errno];
|
|
442
|
-
|
|
443
|
-
message = `${code}: ${errnoMessages[errno]}, ${ctx.syscall}`;
|
|
444
|
-
if (ctx.path)
|
|
445
|
-
message += ` '${ctx.path}'`;
|
|
446
|
-
if (ctx.dest)
|
|
447
|
-
message += ` -> '${ctx.dest}'`;
|
|
448
|
-
}
|
|
449
|
-
super(message);
|
|
442
|
+
super(message || '');
|
|
450
443
|
this.errno = errno;
|
|
451
444
|
this.code = code;
|
|
452
|
-
Object.assign(this, omit(ctx, 'message'
|
|
445
|
+
Object.assign(this, omit(ctx, 'message'));
|
|
446
|
+
if (!message)
|
|
447
|
+
setUVMessage(this);
|
|
453
448
|
Error.captureStackTrace?.(this, this.constructor);
|
|
454
449
|
}
|
|
455
450
|
toString() {
|
|
@@ -484,7 +479,7 @@ export function UV(code, context, path, dest) {
|
|
|
484
479
|
return err;
|
|
485
480
|
}
|
|
486
481
|
/**
|
|
487
|
-
* Shortcut to easily create an `
|
|
482
|
+
* Shortcut to easily create an `Exception` with a specific error code.
|
|
488
483
|
*/
|
|
489
484
|
export function withErrno(code, message) {
|
|
490
485
|
const err = new Exception(Errno[code], message ?? errnoMessages[Errno[code]]);
|