@magic.batua/error
Advanced tools
Comparing version
"use strict"; | ||
// | ||
// index.ts | ||
// Magic-Error | ||
// | ||
// Created on February 18, 2018 by Animesh Mishra <hello@animesh.ltd> | ||
// © 2018 Animesh Ltd. All Rights Reserved. | ||
// | ||
/** | ||
* @module @magic.batua/error | ||
* @overview Defines the `Error` handling interfaces used throughout the Magic Batua | ||
* codebase. | ||
* | ||
* @author Animesh Mishra <hello@animesh.ltd> | ||
* @copyright © 2018 Animesh Ltd. All Rights Reserved. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -17,4 +18,22 @@ const Code_1 = require("./Source/Code"); | ||
/** | ||
* All errors thrown in the application are routed here. | ||
* @exports Error | ||
*/ | ||
exports.description = "Exports error handling functionalities"; | ||
/** | ||
* All the errors thrown by the application code, in any of the modules, | ||
* are routed through this method. | ||
* | ||
* Upon receiving an `error`, the method first runs an identity check. | ||
* | ||
* - If the `error` is of type `ClientError`, it sends an error response with | ||
* one of the 4xx status codes. | ||
* - If the `error` is of type `ExternalError`, it sends an error response with | ||
* a `424 Failed Dependency` status code. | ||
* - If the `error` is of any other type, it's assumed to an internal server | ||
* error and a `500 Internal Server Error` response is sent. | ||
* | ||
* | ||
* Regardless of the error type, each response includes a detailed description, | ||
* help message and debugging information in the response body. | ||
* | ||
* @param { Error } error The error thrown | ||
@@ -21,0 +40,0 @@ * @param { Express.Response } response The response object that will be used to |
"use strict"; | ||
// | ||
// ClientError.ts | ||
// Magic-Error | ||
// | ||
// Created on February 18, 2018 by Animesh Mishra <hello@animesh.ltd> | ||
// © 2018 Animesh Ltd. All Rights Reserved. | ||
// | ||
/** | ||
* @module ClientError | ||
* @overview Defines the `ClientError` class. | ||
* | ||
* @author Animesh Mishra <hello@animesh.ltd> | ||
* @copyright © 2018 Animesh Ltd. All Rights Reserved. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -24,2 +24,4 @@ /** | ||
* @param { string } help Optional debugging help text | ||
* | ||
* @constructor | ||
*/ | ||
@@ -39,2 +41,6 @@ constructor(code, message, help) { | ||
* @returns { any } A `ClientError` object without the `code`. | ||
* | ||
* @function Export | ||
* @memberof ClientError | ||
* @instance | ||
*/ | ||
@@ -41,0 +47,0 @@ Export() { |
"use strict"; | ||
// | ||
// Code.ts | ||
// Magic-Error | ||
// | ||
// Created on February 18, 2018 by Animesh Mishra <hello@animesh.ltd> | ||
// © 2018 Animesh Ltd. All Rights Reserved. | ||
// | ||
/** | ||
* @module Code | ||
* @overview Defines the `Code` enum that encapsulates HTTP status codes used throughout | ||
* the application. | ||
* | ||
* @author Animesh Mishra <hello@animesh.ltd> | ||
* @copyright © 2018 Animesh Ltd. All Rights Reserved. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -13,2 +14,3 @@ /** | ||
* client. | ||
* @exports Code | ||
*/ | ||
@@ -15,0 +17,0 @@ var Code; |
"use strict"; | ||
// | ||
// External-Error.ts | ||
// Magic-Error | ||
// | ||
// Created on February 18, 2018 by Animesh Mishra <hello@animesh.ltd> | ||
// © 2018 Animesh Ltd. All Rights Reserved. | ||
// | ||
/** | ||
* @module ExternalError | ||
* @overview Defines the `ExternalError` class. | ||
* | ||
* @author Animesh Mishra <hello@animesh.ltd> | ||
* @copyright © 2018 Animesh Ltd. All Rights Reserved. | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -28,5 +28,12 @@ const Code_1 = require("./Code"); | ||
* @param { string } help Debugging information | ||
* | ||
* @constructor | ||
*/ | ||
constructor(message, serviceProvider, help) { | ||
super(); | ||
/** | ||
* The error code | ||
* | ||
* @property code | ||
*/ | ||
this.code = Code_1.Code.FailedDependency; | ||
@@ -44,2 +51,6 @@ this.message = message; | ||
* @returns { any } A `ExternalError` object without the `code`. | ||
* | ||
* @function Export | ||
* @memberof ExternalError | ||
* @instance | ||
*/ | ||
@@ -46,0 +57,0 @@ Export() { |
36
index.ts
@@ -1,8 +0,9 @@ | ||
// | ||
// index.ts | ||
// Magic-Error | ||
// | ||
// Created on February 18, 2018 by Animesh Mishra <hello@animesh.ltd> | ||
// © 2018 Animesh Ltd. All Rights Reserved. | ||
// | ||
/** | ||
* @module @magic.batua/error | ||
* @overview Defines the `Error` handling interfaces used throughout the Magic Batua | ||
* codebase. | ||
* | ||
* @author Animesh Mishra <hello@animesh.ltd> | ||
* @copyright © 2018 Animesh Ltd. All Rights Reserved. | ||
*/ | ||
@@ -15,4 +16,23 @@ import * as Express from "express" | ||
/** | ||
* All errors thrown in the application are routed here. | ||
* @exports Error | ||
*/ | ||
export var description = "Exports error handling functionalities" | ||
/** | ||
* All the errors thrown by the application code, in any of the modules, | ||
* are routed through this method. | ||
* | ||
* Upon receiving an `error`, the method first runs an identity check. | ||
* | ||
* - If the `error` is of type `ClientError`, it sends an error response with | ||
* one of the 4xx status codes. | ||
* - If the `error` is of type `ExternalError`, it sends an error response with | ||
* a `424 Failed Dependency` status code. | ||
* - If the `error` is of any other type, it's assumed to an internal server | ||
* error and a `500 Internal Server Error` response is sent. | ||
* | ||
* | ||
* Regardless of the error type, each response includes a detailed description, | ||
* help message and debugging information in the response body. | ||
* | ||
* @param { Error } error The error thrown | ||
@@ -19,0 +39,0 @@ * @param { Express.Response } response The response object that will be used to |
{ | ||
"name": "@magic.batua/error", | ||
"version": "1.0.0", | ||
"version": "2.0.1", | ||
"description": "The Error module powers the error handling features of the Magic Batua.", | ||
@@ -20,3 +20,4 @@ "author": { | ||
"postinstall": "tsc", | ||
"test": "mocha -r ts-node/register Tests/*.spec.ts" | ||
"test": "mocha -r ts-node/register Tests/*.spec.ts", | ||
"code-manual": "tsc && node_modules/.bin/jsdoc --configure jsdoc.json --verbose" | ||
}, | ||
@@ -43,3 +44,7 @@ "repository": { | ||
"typescript": "^2.7.2" | ||
}, | ||
"devDependencies": { | ||
"jsdoc": "^3.5.5", | ||
"postman-jsdoc-theme": "0.0.3" | ||
} | ||
} |
@@ -7,1 +7,29 @@ # Magic Error | ||
## How to work with this module | ||
1. Clone the repository to your computer. | ||
2. Open Terminal (Command Prompt on Windows), `cd` to the project folder and type `npm install`. | ||
This would install all the NPM dependencies for this project, and transpile the Typescript | ||
code to JavaScript. Don't close the Terminal window. | ||
3. Next, type the following in the Terminal window: `npm test`. This would run all the unit test | ||
that I've written for this particular module. If all tests pass, you've got a fully working | ||
`Account` module in front you. | ||
4. To get a sense of the code structure, I'd recommend consulting the `Code Manual`. Code Manual | ||
is a local site that gets generated from the documentation comments I've left in the source code. | ||
To generate `Code Manual` on your computer, open the Terminal, `cd` to the project root and run | ||
`npm run code-manual`. | ||
5. You should now have a `Code Manual` folder at your project root. Open the `index.html` file in | ||
the folder in your favourite browser and enjoy the ride. | ||
6. Make sure you commit any changes made to the source code at regular intervals, and sync the changes | ||
back to the Bitbucket `origin` repository. | ||
## Contact | ||
For queries, you can write to Animesh at [hello@animesh.ltd](mailto:hello@animesh.ltd). Make sure | ||
you have read [this](https://www.chiark.greenend.org.uk/~sgtatham/bugs.html) before firing off a | ||
bug report. |
@@ -1,8 +0,8 @@ | ||
// | ||
// ClientError.ts | ||
// Magic-Error | ||
// | ||
// Created on February 18, 2018 by Animesh Mishra <hello@animesh.ltd> | ||
// © 2018 Animesh Ltd. All Rights Reserved. | ||
// | ||
/** | ||
* @module ClientError | ||
* @overview Defines the `ClientError` class. | ||
* | ||
* @author Animesh Mishra <hello@animesh.ltd> | ||
* @copyright © 2018 Animesh Ltd. All Rights Reserved. | ||
*/ | ||
@@ -29,2 +29,4 @@ import { Code } from "./Code" | ||
* @param { string } help Optional debugging help text | ||
* | ||
* @constructor | ||
*/ | ||
@@ -45,2 +47,6 @@ public constructor(code: Code, message: string, help?: string) { | ||
* @returns { any } A `ClientError` object without the `code`. | ||
* | ||
* @function Export | ||
* @memberof ClientError | ||
* @instance | ||
*/ | ||
@@ -47,0 +53,0 @@ public Export(): any { |
@@ -1,8 +0,9 @@ | ||
// | ||
// Code.ts | ||
// Magic-Error | ||
// | ||
// Created on February 18, 2018 by Animesh Mishra <hello@animesh.ltd> | ||
// © 2018 Animesh Ltd. All Rights Reserved. | ||
// | ||
/** | ||
* @module Code | ||
* @overview Defines the `Code` enum that encapsulates HTTP status codes used throughout | ||
* the application. | ||
* | ||
* @author Animesh Mishra <hello@animesh.ltd> | ||
* @copyright © 2018 Animesh Ltd. All Rights Reserved. | ||
*/ | ||
@@ -12,2 +13,3 @@ /** | ||
* client. | ||
* @exports Code | ||
*/ | ||
@@ -14,0 +16,0 @@ export enum Code { |
@@ -1,10 +0,10 @@ | ||
// | ||
// External-Error.ts | ||
// Magic-Error | ||
// | ||
// Created on February 18, 2018 by Animesh Mishra <hello@animesh.ltd> | ||
// © 2018 Animesh Ltd. All Rights Reserved. | ||
// | ||
/** | ||
* @module ExternalError | ||
* @overview Defines the `ExternalError` class. | ||
* | ||
* @author Animesh Mishra <hello@animesh.ltd> | ||
* @copyright © 2018 Animesh Ltd. All Rights Reserved. | ||
*/ | ||
import { Code } from "./Code"; | ||
import { Code } from "./Code" | ||
@@ -33,2 +33,4 @@ /** | ||
* @param { string } help Debugging information | ||
* | ||
* @constructor | ||
*/ | ||
@@ -49,2 +51,6 @@ public constructor(message: string, serviceProvider: string, help?: string) { | ||
* @returns { any } A `ExternalError` object without the `code`. | ||
* | ||
* @function Export | ||
* @memberof ExternalError | ||
* @instance | ||
*/ | ||
@@ -51,0 +57,0 @@ public Export(): any { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
417232
1578.53%40
135.29%1587
231.32%35
400%2
Infinity%1
Infinity%