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 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
- static With(code, syscall) {
449
- const err = new ErrnoException(Errno[code], errnoMessages[Errno[code]], syscall);
450
- Error.captureStackTrace?.(err, this);
451
- return err;
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kerium",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "POSIX-style errors, logging, and more",
5
5
  "author": "James Prevett <jp@jamespre.dev> (https://jamespre.dev)",
6
6
  "repository": {