|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <title>JSDoc: Source: Error.js</title> |
| 6 | + |
| 7 | + <script src="scripts/prettify/prettify.js"> </script> |
| 8 | + <script src="scripts/prettify/lang-css.js"> </script> |
| 9 | + <!--[if lt IE 9]> |
| 10 | + <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
| 11 | + <![endif]--> |
| 12 | + <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> |
| 13 | + <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> |
| 14 | +</head> |
| 15 | + |
| 16 | +<body> |
| 17 | + |
| 18 | +<div id="main"> |
| 19 | + |
| 20 | + <h1 class="page-title">Source: Error.js</h1> |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + <section> |
| 28 | + <article> |
| 29 | + <pre class="prettyprint source linenums"><code>// Copyright (c) 2021 MC-Market (Mick Capital Pty. Ltd.) |
| 30 | +// MIT License (https://github.com/MC-Market-org/js-api-wrapper/blob/main/LICENSE) |
| 31 | + |
| 32 | +/** A type which represents a parsed error from the API, or an internal wrapper error. */ |
| 33 | +class Error { |
| 34 | + #code; |
| 35 | + #message; |
| 36 | + |
| 37 | + constructor(json) { |
| 38 | + this.#code = json.code; |
| 39 | + this.#message = json.message; |
| 40 | + } |
| 41 | + |
| 42 | + /** Converts this error into a human-readable string. |
| 43 | + * |
| 44 | + * @returns {string} A string representation of this error. |
| 45 | + */ |
| 46 | + toString() { |
| 47 | + return `${this.#code}: ${this.#message}`; |
| 48 | + } |
| 49 | + |
| 50 | + /** Constructs a new Error which originated within the wrapper. |
| 51 | + * |
| 52 | + * @param {string} message The internal error message. |
| 53 | + * @returns {Error} The newly-constructed error. |
| 54 | + */ |
| 55 | + static internal(message) { |
| 56 | + return new Error({code: "InternalWrapperError", message}); |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +exports.Error = Error;</code></pre> |
| 61 | + </article> |
| 62 | + </section> |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +</div> |
| 68 | + |
| 69 | +<nav> |
| 70 | + <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="AlertsHelper.html">AlertsHelper</a></li><li><a href="ConversationsHelper.html">ConversationsHelper</a></li><li><a href="DownloadsHelper.html">DownloadsHelper</a></li><li><a href="Error.html">Error</a></li><li><a href="Http.html">Http</a></li><li><a href="LicensesHelper.html">LicensesHelper</a></li><li><a href="MembersHelper.html">MembersHelper</a></li><li><a href="ProfilePostsHelper.html">ProfilePostsHelper</a></li><li><a href="PurchasesHelper.html">PurchasesHelper</a></li><li><a href="ResourcesHelper.html">ResourcesHelper</a></li><li><a href="ReviewsHelper.html">ReviewsHelper</a></li><li><a href="SortOptions.html">SortOptions</a></li><li><a href="ThreadsHelper.html">ThreadsHelper</a></li><li><a href="Token.html">Token</a></li><li><a href="TokenType.html">TokenType</a></li><li><a href="UpdatesHelper.html">UpdatesHelper</a></li><li><a href="VersionsHelper.html">VersionsHelper</a></li><li><a href="Wrapper.html">Wrapper</a></li></ul> |
| 71 | +</nav> |
| 72 | + |
| 73 | +<br class="clear"> |
| 74 | + |
| 75 | +<footer> |
| 76 | + Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a> on Sat Jan 15 2022 23:23:21 GMT+0000 (Greenwich Mean Time) |
| 77 | +</footer> |
| 78 | + |
| 79 | +<script> prettyPrint(); </script> |
| 80 | +<script src="scripts/linenumber.js"> </script> |
| 81 | +</body> |
| 82 | +</html> |
0 commit comments