@webiny/error 5.23.1 → 5.25.0-beta.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/Error.d.ts +6 -7
- package/Error.js +13 -11
- package/Error.js.map +1 -0
- package/index.d.ts +2 -1
- package/index.js +11 -3
- package/index.js.map +1 -0
- package/package.json +5 -5
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
|
@@ -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,"sources":["Error.ts"],"names":["WError","Error","constructor","messageOrOptions","code","data","message","from","err","options","Object","assign"],"mappings":";;;;;;;;;;;AAMe,MAAMA,MAAN,SAAkCC,KAAlC,CAAwC;AAMnDC,EAAAA,WAAW,CAACC,gBAAD,EAAiDC,IAAjD,EAAgEC,IAAhE,EAA8E;AACrF;AACA,UAAM,OAAOF,gBAAP,KAA4B,QAA5B,GAAuCA,gBAAvC,GAA0DA,gBAAgB,CAACG,OAAjF;AAFqF,gDALnD,IAKmD;AAAA,gDAJpD,IAIoD;;AAIrF,QAAI,OAAOH,gBAAP,KAA4B,QAAhC,EAA0C;AACtC;AACA,WAAKC,IAAL,GAAYA,IAAI,IAAI,IAApB;AACA,WAAKC,IAAL,GAAYA,IAAI,IAAI,IAApB;AACH,KAJD,MAIO;AACH;AACA,WAAKD,IAAL,GAAYD,gBAAgB,CAACC,IAAjB,IAAyB,IAArC;AACA,WAAKC,IAAL,GAAYF,gBAAgB,CAACE,IAAjB,IAAyB,IAArC;AACH;AACJ;;AAEiB,SAAJE,IAAI,CAAcC,GAAd,EAAoCC,OAA4B,GAAG,EAAnE,EAAuE;AACrF,WAAO,IAAIT,MAAJ,CAAW;AACdM,MAAAA,OAAO,EAAEE,GAAG,CAACF,OAAJ,IAAeG,OAAO,CAACH,OADlB;AAEdF,MAAAA,IAAI,EAAEI,GAAG,CAACJ,IAAJ,IAAYK,OAAO,CAACL,IAFZ;AAGdC,MAAAA,IAAI,EAAEK,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBH,GAAG,CAACH,IAAtB,EAA4BI,OAAO,CAACJ,IAApC;AAHQ,KAAX,CAAP;AAKH;;AA3BkD","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"]}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "ErrorOptions", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Error.ErrorOptions;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
8
12
|
exports.default = void 0;
|
|
9
13
|
|
|
10
|
-
var _Error =
|
|
14
|
+
var _Error = _interopRequireWildcard(require("./Error"));
|
|
15
|
+
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
19
|
|
|
12
20
|
var _default = _Error.default;
|
|
13
21
|
exports.default = _default;
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["Error"],"mappings":";;;;;;;;;;;;;AAAA;;;;;;eAEeA,c","sourcesContent":["import Error, { ErrorOptions } from \"./Error\";\n\nexport default Error;\nexport { ErrorOptions };\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/error",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.25.0-beta.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@babel/cli": "^7.16.0",
|
|
18
18
|
"@babel/core": "^7.16.0",
|
|
19
|
-
"@webiny/cli": "^5.
|
|
20
|
-
"@webiny/project-utils": "^5.
|
|
19
|
+
"@webiny/cli": "^5.25.0-beta.0",
|
|
20
|
+
"@webiny/project-utils": "^5.25.0-beta.0",
|
|
21
21
|
"rimraf": "^3.0.2",
|
|
22
|
-
"typescript": "
|
|
22
|
+
"typescript": "4.5.5"
|
|
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": "2d3e7833575e88fde77d84e5490e746933a5ec28"
|
|
29
29
|
}
|