@rxstack/exceptions
Advanced tools
| import { Exception } from './exception'; | ||
| /** | ||
| * Transform an error to exception | ||
| * | ||
| * @param e | ||
| * @returns {Exception} | ||
| */ | ||
| export declare function transformToException(e: any): Exception; | ||
| export declare function exceptionToObject(e: Exception, context?: any): Object; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const exception_1 = require("./exception"); | ||
| /** | ||
| * Transform an error to exception | ||
| * | ||
| * @param e | ||
| * @returns {Exception} | ||
| */ | ||
| function transformToException(e) { | ||
| const errorStack = e.stack; | ||
| if (!(e instanceof exception_1.Exception)) { | ||
| e = new exception_1.Exception(e.message); | ||
| e.stack = errorStack; | ||
| } | ||
| return e; | ||
| function exceptionToObject(e, context) { | ||
| return { | ||
| message: e.message, | ||
| stack: e.stack, | ||
| data: e.data, | ||
| context: context | ||
| }; | ||
| } | ||
| exports.transformToException = transformToException; | ||
| exports.exceptionToObject = exceptionToObject; | ||
| //# sourceMappingURL=exception-to-object.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"exception-to-object.js","sourceRoot":"","sources":["../src/exception-to-object.ts"],"names":[],"mappings":";;AAAA,2CAAsC;AAEtC;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,CAAM;IACzC,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC;IAC3B,IAAI,CAAC,CAAC,CAAC,YAAY,qBAAS,CAAC,EAAE;QAC7B,CAAC,GAAG,IAAI,qBAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC;KACtB;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAPD,oDAOC"} | ||
| {"version":3,"file":"exception-to-object.js","sourceRoot":"","sources":["../src/exception-to-object.ts"],"names":[],"mappings":";;AAEA,SAAgB,iBAAiB,CAAC,CAAY,EAAE,OAAa;IAC3D,OAAO;QACL,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,OAAO,EAAE,OAAO;KACjB,CAAC;AACJ,CAAC;AAPD,8CAOC"} |
+2
-2
@@ -23,3 +23,3 @@ export * from './bad-request.exception'; | ||
| export * from './too-many-requests.exception'; | ||
| export * from './transform-to-exception'; | ||
| export * from './exception-to-object'; | ||
| export * from './unauthorized.exception'; | ||
@@ -30,2 +30,2 @@ export * from './unavailable-for-legal-reasons.exception'; | ||
| export * from './uri-too-long.exception'; | ||
| export * from './exception-to-object'; | ||
| export * from './transform-to-exception'; |
+2
-2
@@ -28,3 +28,3 @@ "use strict"; | ||
| __export(require("./too-many-requests.exception")); | ||
| __export(require("./transform-to-exception")); | ||
| __export(require("./exception-to-object")); | ||
| __export(require("./unauthorized.exception")); | ||
@@ -35,3 +35,3 @@ __export(require("./unavailable-for-legal-reasons.exception")); | ||
| __export(require("./uri-too-long.exception")); | ||
| __export(require("./exception-to-object")); | ||
| __export(require("./transform-to-exception")); | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,6CAAwC;AACxC,0CAAqC;AACrC,iCAA4B;AAC5B,oDAA+C;AAC/C,2CAAsC;AACtC,sCAAiC;AACjC,sCAAiC;AACjC,sDAAiD;AACjD,uDAAkD;AAClD,iDAA4C;AAC5C,oDAA+C;AAC/C,gDAA2C;AAC3C,2CAAsC;AACtC,iDAA4C;AAC5C,mDAA8C;AAC9C,kDAA6C;AAC7C,sDAAiD;AACjD,+DAA0D;AAC1D,uDAAkD;AAClD,iDAA4C;AAC5C,qDAAgD;AAChD,mDAA8C;AAC9C,8CAAyC;AACzC,8CAAyC;AACzC,+DAA0D;AAC1D,sDAAiD;AACjD,wDAAmD;AACnD,8CAAyC;AACzC,2CAAsC"} | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,6CAAwC;AACxC,0CAAqC;AACrC,iCAA4B;AAC5B,oDAA+C;AAC/C,2CAAsC;AACtC,sCAAiC;AACjC,sCAAiC;AACjC,sDAAiD;AACjD,uDAAkD;AAClD,iDAA4C;AAC5C,oDAA+C;AAC/C,gDAA2C;AAC3C,2CAAsC;AACtC,iDAA4C;AAC5C,mDAA8C;AAC9C,kDAA6C;AAC7C,sDAAiD;AACjD,+DAA0D;AAC1D,uDAAkD;AAClD,iDAA4C;AAC5C,qDAAgD;AAChD,mDAA8C;AAC9C,2CAAsC;AACtC,8CAAyC;AACzC,+DAA0D;AAC1D,sDAAiD;AACjD,wDAAmD;AACnD,8CAAyC;AACzC,8CAAyC"} |
| import { Exception } from './exception'; | ||
| export declare function exceptionToObject(e: Exception, context?: any): Object; | ||
| /** | ||
| * Transform an error to exception | ||
| * | ||
| * @param e | ||
| * @returns {Exception} | ||
| */ | ||
| export declare function transformToException(e: any): Exception; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| function exceptionToObject(e, context) { | ||
| return { | ||
| message: e.message, | ||
| stack: e.stack, | ||
| data: e.data, | ||
| context: context | ||
| }; | ||
| const exception_1 = require("./exception"); | ||
| /** | ||
| * Transform an error to exception | ||
| * | ||
| * @param e | ||
| * @returns {Exception} | ||
| */ | ||
| function transformToException(e) { | ||
| const name = e.name; | ||
| const errorStack = e.stack; | ||
| if (!(e instanceof exception_1.Exception)) { | ||
| e = new exception_1.Exception(e.message); | ||
| e.name = name; | ||
| e.stack = errorStack; | ||
| } | ||
| return e; | ||
| } | ||
| exports.exceptionToObject = exceptionToObject; | ||
| exports.transformToException = transformToException; | ||
| //# sourceMappingURL=transform-to-exception.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"transform-to-exception.js","sourceRoot":"","sources":["../src/transform-to-exception.ts"],"names":[],"mappings":";;AAEA,SAAgB,iBAAiB,CAAC,CAAY,EAAE,OAAa;IAC3D,OAAO;QACL,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,OAAO,EAAE,OAAO;KACjB,CAAC;AACJ,CAAC;AAPD,8CAOC"} | ||
| {"version":3,"file":"transform-to-exception.js","sourceRoot":"","sources":["../src/transform-to-exception.ts"],"names":[],"mappings":";;AAAA,2CAAsC;AAEtC;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,CAAM;IACzC,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;IACpB,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC;IAC3B,IAAI,CAAC,CAAC,CAAC,YAAY,qBAAS,CAAC,EAAE;QAC7B,CAAC,GAAG,IAAI,qBAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;QACd,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC;KACtB;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AATD,oDASC"} |
+8
-18
| { | ||
| "name": "@rxstack/exceptions", | ||
| "version": "0.1.3", | ||
| "version": "0.1.4", | ||
| "description": "RxStack Exceptions Component", | ||
| "private": false, | ||
| "author": "Nikolay Gergiev <symfonist@gmail.com>", | ||
| "author": "Nikolay Georgiev <symfonist@gmail.com>", | ||
| "license": "MIT", | ||
@@ -13,3 +13,3 @@ "repository": { | ||
| "engines": { | ||
| "node": ">=8" | ||
| "node": ">=9" | ||
| }, | ||
@@ -32,13 +32,12 @@ "keywords": [ | ||
| "devDependencies": { | ||
| "@types/chai": "^4.1.2", | ||
| "@types/chai": "^4.1.7", | ||
| "@types/mocha": "^2.2.48", | ||
| "chai": "3.5.0", | ||
| "mocha": "^5.2.0", | ||
| "nyc": "^13.3.0", | ||
| "should": "^13.2.3", | ||
| "istanbul": "0.4.5", | ||
| "mocha": "^5.2.0", | ||
| "nyc": "^11.0.3", | ||
| "source-map-support": "^0.4.15", | ||
| "ts-node": "^3.1.0", | ||
| "tslint": "^5.9.1", | ||
| "typescript": "^3.0" | ||
| "tslint": "^5.13.1", | ||
| "typescript": "^3.3.3333" | ||
| }, | ||
@@ -55,14 +54,5 @@ "bugs": { | ||
| "nyc": { | ||
| "include": [ | ||
| "./src/**/*.ts" | ||
| ], | ||
| "exclude": [ | ||
| "./test/**/*.spec.ts" | ||
| ], | ||
| "extension": [ | ||
| ".ts" | ||
| ], | ||
| "require": [ | ||
| "ts-node/register" | ||
| ], | ||
| "reporter": [ | ||
@@ -69,0 +59,0 @@ "text-summary", |
10
-9.09%623
0.32%35911
-0.11%