@webiny/error 0.0.0-mt-3 → 0.0.0-unstable.1e66d121db
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/Error.d.ts +6 -7
- package/Error.js +14 -12
- package/Error.js.map +1 -0
- package/index.d.ts +2 -1
- package/index.js +8 -2
- package/index.js.map +1 -0
- package/package.json +7 -7
package/Error.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
interface ErrorOptions<TData> {
|
|
1
|
+
export interface ErrorOptions<TData = any> {
|
|
2
2
|
message?: string;
|
|
3
3
|
code?: string;
|
|
4
4
|
data?: TData;
|
|
5
5
|
}
|
|
6
6
|
export default class WError<TData = any> extends Error {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
data?: TData;
|
|
10
|
-
constructor(
|
|
11
|
-
static from<TData = any>(err:
|
|
7
|
+
readonly code: string | null;
|
|
8
|
+
readonly data: TData | null;
|
|
9
|
+
constructor(message: string, code?: string, data?: TData);
|
|
10
|
+
constructor(options: ErrorOptions<TData>);
|
|
11
|
+
static from<TData = any>(err: Partial<WError>, options?: ErrorOptions<TData>): WError<any>;
|
|
12
12
|
}
|
|
13
|
-
export {};
|
package/Error.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -10,18 +10,20 @@ exports.default = void 0;
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
12
12
|
class WError extends Error {
|
|
13
|
-
constructor(
|
|
14
|
-
|
|
15
|
-
(
|
|
16
|
-
(0, _defineProperty2.default)(this, "code",
|
|
17
|
-
(0, _defineProperty2.default)(this, "data",
|
|
18
|
-
|
|
19
|
-
if (typeof
|
|
20
|
-
|
|
21
|
-
this.code = code;
|
|
22
|
-
this.data = data;
|
|
13
|
+
constructor(messageOrOptions, code, data) {
|
|
14
|
+
// TODO in TS 4.6 we can move that into if statements
|
|
15
|
+
super(typeof messageOrOptions === "string" ? messageOrOptions : messageOrOptions.message);
|
|
16
|
+
(0, _defineProperty2.default)(this, "code", null);
|
|
17
|
+
(0, _defineProperty2.default)(this, "data", null);
|
|
18
|
+
|
|
19
|
+
if (typeof messageOrOptions === "string") {
|
|
20
|
+
// super(messageOrOptions); - use after TS 4.6
|
|
21
|
+
this.code = code || null;
|
|
22
|
+
this.data = data || null;
|
|
23
23
|
} else {
|
|
24
|
-
|
|
24
|
+
// super(messageOrOptions.message); - use after TS 4.6
|
|
25
|
+
this.code = messageOrOptions.code || null;
|
|
26
|
+
this.data = messageOrOptions.data || null;
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
|
package/Error.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["WError","Error","constructor","messageOrOptions","code","data","message","from","err","options","Object","assign"],"sources":["Error.ts"],"sourcesContent":["export interface ErrorOptions<TData = any> {\n message?: string;\n code?: string;\n data?: TData;\n}\n\nexport default class WError<TData = any> extends Error {\n public readonly code: string | null = null;\n public readonly data: TData | null = null;\n\n constructor(message: string, code?: string, data?: TData);\n constructor(options: ErrorOptions<TData>);\n constructor(messageOrOptions: string | ErrorOptions<TData>, code?: string, data?: TData) {\n // TODO in TS 4.6 we can move that into if statements\n super(typeof messageOrOptions === \"string\" ? messageOrOptions : messageOrOptions.message);\n\n if (typeof messageOrOptions === \"string\") {\n // super(messageOrOptions); - use after TS 4.6\n this.code = code || null;\n this.data = data || null;\n } else {\n // super(messageOrOptions.message); - use after TS 4.6\n this.code = messageOrOptions.code || null;\n this.data = messageOrOptions.data || null;\n }\n }\n\n public static from<TData = any>(err: Partial<WError>, options: ErrorOptions<TData> = {}) {\n return new WError({\n message: err.message || options.message,\n code: err.code || options.code,\n data: Object.assign({}, err.data, options.data)\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AAMe,MAAMA,MAAN,SAAkCC,KAAlC,CAAwC;EAMnDC,WAAW,CAACC,gBAAD,EAAiDC,IAAjD,EAAgEC,IAAhE,EAA8E;IACrF;IACA,MAAM,OAAOF,gBAAP,KAA4B,QAA5B,GAAuCA,gBAAvC,GAA0DA,gBAAgB,CAACG,OAAjF;IAFqF,4CALnD,IAKmD;IAAA,4CAJpD,IAIoD;;IAIrF,IAAI,OAAOH,gBAAP,KAA4B,QAAhC,EAA0C;MACtC;MACA,KAAKC,IAAL,GAAYA,IAAI,IAAI,IAApB;MACA,KAAKC,IAAL,GAAYA,IAAI,IAAI,IAApB;IACH,CAJD,MAIO;MACH;MACA,KAAKD,IAAL,GAAYD,gBAAgB,CAACC,IAAjB,IAAyB,IAArC;MACA,KAAKC,IAAL,GAAYF,gBAAgB,CAACE,IAAjB,IAAyB,IAArC;IACH;EACJ;;EAEiB,OAAJE,IAAI,CAAcC,GAAd,EAAoCC,OAA4B,GAAG,EAAnE,EAAuE;IACrF,OAAO,IAAIT,MAAJ,CAAW;MACdM,OAAO,EAAEE,GAAG,CAACF,OAAJ,IAAeG,OAAO,CAACH,OADlB;MAEdF,IAAI,EAAEI,GAAG,CAACJ,IAAJ,IAAYK,OAAO,CAACL,IAFZ;MAGdC,IAAI,EAAEK,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBH,GAAG,CAACH,IAAtB,EAA4BI,OAAO,CAACJ,IAApC;IAHQ,CAAX,CAAP;EAKH;;AA3BkD"}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
Object.defineProperty(exports, "ErrorOptions", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return _Error.ErrorOptions;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
8
14
|
exports.default = void 0;
|
|
9
15
|
|
|
10
|
-
var _Error =
|
|
16
|
+
var _Error = _interopRequireWildcard(require("./Error"));
|
|
11
17
|
|
|
12
18
|
var _default = _Error.default;
|
|
13
19
|
exports.default = _default;
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Error"],"sources":["index.ts"],"sourcesContent":["import Error, { ErrorOptions } from \"./Error\";\n\nexport default Error;\nexport { ErrorOptions };\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;eAEeA,c"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/error",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-unstable.1e66d121db",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"directory": "dist"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@babel/cli": "^7.
|
|
18
|
-
"@babel/core": "^7.
|
|
19
|
-
"@webiny/cli": "^0.0.0-
|
|
20
|
-
"@webiny/project-utils": "^0.0.0-
|
|
17
|
+
"@babel/cli": "^7.19.3",
|
|
18
|
+
"@babel/core": "^7.19.3",
|
|
19
|
+
"@webiny/cli": "^0.0.0-unstable.1e66d121db",
|
|
20
|
+
"@webiny/project-utils": "^0.0.0-unstable.1e66d121db",
|
|
21
21
|
"rimraf": "^3.0.2",
|
|
22
|
-
"typescript": "
|
|
22
|
+
"typescript": "4.7.4"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "yarn webiny run build",
|
|
26
26
|
"watch": "yarn webiny run watch"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "b670bf27c5039de1a2b0be764a09ba4cb94ad5e2"
|
|
29
29
|
}
|