@webiny/error 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f

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 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
- message: string;
8
- code?: string;
9
- data?: TData;
10
- constructor(message: string | ErrorOptions<TData>, code?: string, data?: TData);
11
- static from<TData = any>(err: any, options?: ErrorOptions<TData>): WError<any>;
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,30 +1,25 @@
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
  });
8
6
  exports.default = void 0;
9
-
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
7
  class WError extends Error {
13
- constructor(message, code = null, data = null) {
14
- super();
15
- (0, _defineProperty2.default)(this, "message", void 0);
16
- (0, _defineProperty2.default)(this, "code", void 0);
17
- (0, _defineProperty2.default)(this, "data", void 0);
18
-
19
- if (typeof message === "string") {
20
- this.message = message;
21
- this.code = code;
22
- this.data = data;
8
+ code = null;
9
+ data = null;
10
+ constructor(messageOrOptions, code, data) {
11
+ // TODO in TS 4.6 we can move that into if statements
12
+ super(typeof messageOrOptions === "string" ? messageOrOptions : messageOrOptions.message);
13
+ if (typeof messageOrOptions === "string") {
14
+ // super(messageOrOptions); - use after TS 4.6
15
+ this.code = code || null;
16
+ this.data = data || null;
23
17
  } else {
24
- Object.assign(this, message);
18
+ // super(messageOrOptions.message); - use after TS 4.6
19
+ this.code = messageOrOptions.code || null;
20
+ this.data = messageOrOptions.data || null;
25
21
  }
26
22
  }
27
-
28
23
  static from(err, options = {}) {
29
24
  return new WError({
30
25
  message: err.message || options.message,
@@ -32,7 +27,7 @@ class WError extends Error {
32
27
  data: Object.assign({}, err.data, options.data)
33
28
  });
34
29
  }
35
-
36
30
  }
31
+ exports.default = WError;
37
32
 
38
- exports.default = WError;
33
+ //# sourceMappingURL=Error.js.map
package/Error.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["WError","Error","code","data","constructor","messageOrOptions","message","from","err","options","Object","assign","exports","default"],"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,MAAM,SAAsBC,KAAK,CAAC;EACnCC,IAAI,GAAkB,IAAI;EAC1BC,IAAI,GAAiB,IAAI;EAIzCC,WAAWA,CAACC,gBAA8C,EAAEH,IAAa,EAAEC,IAAY,EAAE;IACrF;IACA,KAAK,CAAC,OAAOE,gBAAgB,KAAK,QAAQ,GAAGA,gBAAgB,GAAGA,gBAAgB,CAACC,OAAO,CAAC;IAEzF,IAAI,OAAOD,gBAAgB,KAAK,QAAQ,EAAE;MACtC;MACA,IAAI,CAACH,IAAI,GAAGA,IAAI,IAAI,IAAI;MACxB,IAAI,CAACC,IAAI,GAAGA,IAAI,IAAI,IAAI;IAC5B,CAAC,MAAM;MACH;MACA,IAAI,CAACD,IAAI,GAAGG,gBAAgB,CAACH,IAAI,IAAI,IAAI;MACzC,IAAI,CAACC,IAAI,GAAGE,gBAAgB,CAACF,IAAI,IAAI,IAAI;IAC7C;EACJ;EAEA,OAAcI,IAAIA,CAAcC,GAAoB,EAAEC,OAA4B,GAAG,CAAC,CAAC,EAAE;IACrF,OAAO,IAAIT,MAAM,CAAC;MACdM,OAAO,EAAEE,GAAG,CAACF,OAAO,IAAIG,OAAO,CAACH,OAAO;MACvCJ,IAAI,EAAEM,GAAG,CAACN,IAAI,IAAIO,OAAO,CAACP,IAAI;MAC9BC,IAAI,EAAEO,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEH,GAAG,CAACL,IAAI,EAAEM,OAAO,CAACN,IAAI;IAClD,CAAC,CAAC;EACN;AACJ;AAACS,OAAA,CAAAC,OAAA,GAAAb,MAAA","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
- import Error from "./Error";
1
+ import Error, { ErrorOptions } from "./Error";
2
+ export { Error as WebinyError };
2
3
  export default Error;
4
+ export { ErrorOptions };
package/index.js CHANGED
@@ -1,13 +1,23 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
7
+ Object.defineProperty(exports, "ErrorOptions", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _Error.ErrorOptions;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "WebinyError", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _Error.default;
17
+ }
18
+ });
8
19
  exports.default = void 0;
20
+ var _Error = _interopRequireWildcard(require("./Error"));
21
+ var _default = exports.default = _Error.default;
9
22
 
10
- var _Error = _interopRequireDefault(require("./Error"));
11
-
12
- var _default = _Error.default;
13
- exports.default = _default;
23
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_Error","_interopRequireWildcard","require","_default","exports","default","Error"],"sources":["index.ts"],"sourcesContent":["import Error, { ErrorOptions } from \"./Error\";\n\nexport { Error as WebinyError };\nexport default Error;\nexport { ErrorOptions };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA8C,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAG/BC,cAAK","ignoreList":[]}
package/package.json CHANGED
@@ -1,29 +1,26 @@
1
1
  {
2
- "name": "@webiny/error",
3
- "version": "0.0.0-mt-2",
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.12.10",
18
- "@babel/core": "^7.5.5",
19
- "@webiny/cli": "^0.0.0-mt-2",
20
- "@webiny/project-utils": "^0.0.0-mt-2",
21
- "rimraf": "^3.0.2",
22
- "typescript": "^4.1.3"
23
- },
24
- "scripts": {
25
- "build": "yarn webiny run build",
26
- "watch": "yarn webiny run watch"
27
- },
28
- "gitHead": "3c0dcfb3c22c9f83107fdb97b25014cd03d9db7d"
2
+ "name": "@webiny/error",
3
+ "version": "0.0.0-unstable.06b2ede40f",
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
+ "@webiny/project-utils": "0.0.0-unstable.06b2ede40f",
18
+ "rimraf": "6.0.1",
19
+ "typescript": "5.3.3"
20
+ },
21
+ "scripts": {
22
+ "build": "node ../cli/bin.js run build",
23
+ "watch": "node ../cli/bin.js run watch"
24
+ },
25
+ "gitHead": "06b2ede40fc2212a70eeafd74afd50b56fb0ce82"
29
26
  }