@webiny/error 0.0.0-ee-vpcs.549378cf03
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 +12 -0
- package/Error.js +40 -0
- package/Error.js.map +1 -0
- package/LICENSE +21 -0
- package/README.md +20 -0
- package/index.d.ts +3 -0
- package/index.js +19 -0
- package/index.js.map +1 -0
- package/package.json +29 -0
package/Error.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ErrorOptions<TData = any> {
|
|
2
|
+
message?: string;
|
|
3
|
+
code?: string;
|
|
4
|
+
data?: TData;
|
|
5
|
+
}
|
|
6
|
+
export default class WError<TData = any> extends Error {
|
|
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
|
+
}
|
package/Error.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
class WError extends Error {
|
|
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
|
+
} else {
|
|
24
|
+
// super(messageOrOptions.message); - use after TS 4.6
|
|
25
|
+
this.code = messageOrOptions.code || null;
|
|
26
|
+
this.data = messageOrOptions.data || null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static from(err, options = {}) {
|
|
31
|
+
return new WError({
|
|
32
|
+
message: err.message || options.message,
|
|
33
|
+
code: err.code || options.code,
|
|
34
|
+
data: Object.assign({}, err.data, options.data)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
exports.default = WError;
|
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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @webiny/error
|
|
2
|
+
[](https://www.npmjs.com/package/webiny-data)
|
|
3
|
+
[](https://www.npmjs.com/package/webiny-data)
|
|
4
|
+
[](https://github.com/prettier/prettier)
|
|
5
|
+
[](http://makeapullrequest.com)
|
|
6
|
+
|
|
7
|
+
A set of frequently used data higher order functions.
|
|
8
|
+
|
|
9
|
+
For more information, please visit
|
|
10
|
+
[the official docs](https://github.com/doitadrian/data).
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
```
|
|
14
|
+
npm install --save @webiny/error
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Or if you prefer yarn:
|
|
18
|
+
```
|
|
19
|
+
yarn add @webiny/error
|
|
20
|
+
```
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "ErrorOptions", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return _Error.ErrorOptions;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
exports.default = void 0;
|
|
15
|
+
|
|
16
|
+
var _Error = _interopRequireWildcard(require("./Error"));
|
|
17
|
+
|
|
18
|
+
var _default = _Error.default;
|
|
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
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/error",
|
|
3
|
+
"version": "0.0.0-ee-vpcs.549378cf03",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"types": "index.d.ts",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/webiny/webiny-js.git"
|
|
9
|
+
},
|
|
10
|
+
"description": "A simple multi-database client.",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public",
|
|
14
|
+
"directory": "dist"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@babel/cli": "^7.19.3",
|
|
18
|
+
"@babel/core": "^7.19.3",
|
|
19
|
+
"@webiny/cli": "^0.0.0-ee-vpcs.549378cf03",
|
|
20
|
+
"@webiny/project-utils": "^0.0.0-ee-vpcs.549378cf03",
|
|
21
|
+
"rimraf": "^3.0.2",
|
|
22
|
+
"typescript": "4.7.4"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "yarn webiny run build",
|
|
26
|
+
"watch": "yarn webiny run watch"
|
|
27
|
+
},
|
|
28
|
+
"gitHead": "549378cf03fcd27845fc3fa23d1dc6b32896f630"
|
|
29
|
+
}
|