UNPKG

@magic.batua/error

Version:

The Error module powers the error handling features of the Magic Batua.

121 lines (100 loc) 4.1 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Source/ExternalError.js - Postman Documentation</title> <script src="scripts/prettify/prettify.js"></script> <script src="scripts/prettify/lang-css.js"></script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/ionicons.min.css"> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <input type="checkbox" id="nav-trigger" class="nav-trigger" /> <label for="nav-trigger" class="navicon-button x"> <div class="navicon"></div> </label> <label for="nav-trigger" class="overlay"></label> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="ClientError.html">ClientError</a><ul class='methods'><li data-type='method'><a href="ClientError.html#Export">Export</a></li></ul></li><li><a href="ExternalError.html">ExternalError</a><ul class='methods'><li data-type='method'><a href="ExternalError.html#Export">Export</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-Code.html">Code</a></li><li><a href="module-Error.html">Error</a><ul class='methods'><li data-type='method'><a href="module-Error.html#~Handle">Handle</a></li></ul></li></ul> </nav> <div id="main"> <h1 class="page-title">Source/ExternalError.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>"use strict"; /** * @module ExternalError * @overview Defines the `ExternalError` class. * * @author Animesh Mishra &lt;hello@animesh.ltd> * @copyright © 2018 Animesh Ltd. All Rights Reserved. */ Object.defineProperty(exports, "__esModule", { value: true }); const Code_1 = require("./Code"); /** * The `ExternalError` class represents errors reported by third-party service * providers the code makes use of. This includes, but is not limited to, Azure * Cosmos database, the SMS provider, the Wallet API and the MVC API. * * An `ExternalError` is always reported with a status code of `Codes.FailedDependency`, * i.e. `424`. */ class ExternalError extends Error { /** * Initialises an `ExternalError` with a custom error message, the name of the * service provider or API from where the error originated and an optional debugging * help text. * * @param { string } message The error message * @param { string } serviceProvider Name of the service provider or API throwing the error * @param { string } help Debugging information * * @constructor */ constructor(message, serviceProvider, help) { super(); /** * The error code * * @property code */ this.code = Code_1.Code.FailedDependency; this.message = message; this.serviceProvider = serviceProvider; this.help = help; } /** * Sanitises a `ExternalError` object by getting rid of the `code` property. Sending the * `code` property client-side could make the impression that client shouldn't pay * attention to the HTTP response's `status` header and should code against the response * body's `code` property instead. That would be a bad design choice. * * @returns { any } A `ExternalError` object without the `code`. * * @function Export * @memberof ExternalError * @instance */ Export() { let publicView = JSON.parse(JSON.stringify(this)); delete publicView.code; return publicView; } } exports.ExternalError = ExternalError; //# sourceMappingURL=ExternalError.js.map</code></pre> </article> </section> </div> <br class="clear"> <footer> Documentation generated at Mon Mar 19 2018 23:41:29 GMT+0530 (IST) </footer> <script>prettyPrint();</script> <script src="scripts/linenumber.js"></script> </body> </html>