@stacksjs/error-handling 0.70.57 → 0.70.58

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/model.js ADDED
@@ -0,0 +1,8 @@
1
+ export class ModelNotFoundException extends Error {
2
+ status;
3
+ constructor(status, message) {
4
+ super(message);
5
+ this.status = status;
6
+ this.name = "ModelNotFoundException";
7
+ }
8
+ }
package/dist/utils.js ADDED
@@ -0,0 +1,17 @@
1
+ import { ErrorHandler } from "./handler";
2
+ export function rescue(fn, fallback, onError) {
3
+ try {
4
+ const result = fn();
5
+ if (result instanceof Promise)
6
+ return result.catch((error) => {
7
+ if (onError)
8
+ onError(ErrorHandler.handle(error));
9
+ return fallback;
10
+ });
11
+ return result;
12
+ } catch (error) {
13
+ if (onError)
14
+ onError(ErrorHandler.handle(error));
15
+ return fallback;
16
+ }
17
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/error-handling",
3
3
  "type": "module",
4
- "version": "0.70.57",
4
+ "version": "0.70.58",
5
5
  "description": "Type safe error handling.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [
@@ -57,12 +57,12 @@
57
57
  "ts-syntax-highlighter": "^0.2.1"
58
58
  },
59
59
  "devDependencies": {
60
- "@stacksjs/cli": "0.70.57",
61
- "@stacksjs/config": "0.70.57",
60
+ "@stacksjs/cli": "0.70.58",
61
+ "@stacksjs/config": "0.70.58",
62
62
  "better-dx": "^0.2.12",
63
- "@stacksjs/path": "0.70.57",
64
- "@stacksjs/types": "0.70.57",
65
- "@stacksjs/validation": "0.70.57"
63
+ "@stacksjs/path": "0.70.58",
64
+ "@stacksjs/types": "0.70.58",
65
+ "@stacksjs/validation": "0.70.58"
66
66
  },
67
67
  "sideEffects": false
68
68
  }