kerium 1.1.0 → 1.2.0
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 +5 -2
- package/dist/error.js +8 -5
- package/package.json +1 -1
package/dist/error.d.ts
CHANGED
|
@@ -431,7 +431,10 @@ export declare class ErrnoException extends Error implements NodeJS.ErrnoExcepti
|
|
|
431
431
|
constructor(errno: Errno, message?: string, syscall?: string);
|
|
432
432
|
toString(): string;
|
|
433
433
|
toJSON(): ErrnoExceptionJSON;
|
|
434
|
-
static fromJSON(json: ErrnoExceptionJSON): ErrnoException;
|
|
435
|
-
static With(code: keyof typeof Errno, syscall?: string): ErrnoException;
|
|
434
|
+
static fromJSON(this: void, json: ErrnoExceptionJSON): ErrnoException;
|
|
436
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* Shortcut to easily create an `ErrnoException` with a specific error code.
|
|
438
|
+
*/
|
|
439
|
+
export declare function withErrno(this: void, code: keyof typeof Errno, syscall?: string, message?: string): ErrnoException;
|
|
437
440
|
export {};
|
package/dist/error.js
CHANGED
|
@@ -445,9 +445,12 @@ export class ErrnoException extends Error {
|
|
|
445
445
|
err.stack = json.stack;
|
|
446
446
|
return err;
|
|
447
447
|
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Shortcut to easily create an `ErrnoException` with a specific error code.
|
|
451
|
+
*/
|
|
452
|
+
export function withErrno(code, syscall, message) {
|
|
453
|
+
const err = new ErrnoException(Errno[code], message ?? errnoMessages[Errno[code]], syscall);
|
|
454
|
+
Error.captureStackTrace?.(err, withErrno);
|
|
455
|
+
return err;
|
|
453
456
|
}
|