buddy

node MVC discord bot
Log | Files | Refs | README

HTTPError.js (660B)


      1 'use strict';
      2 
      3 /**
      4  * Represents a HTTP error from a request.
      5  * @extends Error
      6  */
      7 class HTTPError extends Error {
      8   constructor(message, name, code, method, path) {
      9     super(message);
     10 
     11     /**
     12      * The name of the error
     13      * @type {string}
     14      */
     15     this.name = name;
     16 
     17     /**
     18      * HTTP error code returned from the request
     19      * @type {number}
     20      */
     21     this.code = code || 500;
     22 
     23     /**
     24      * The HTTP method used for the request
     25      * @type {string}
     26      */
     27     this.method = method;
     28 
     29     /**
     30      * The path of the request relative to the HTTP endpoint
     31      * @type {string}
     32      */
     33     this.path = path;
     34   }
     35 }
     36 
     37 module.exports = HTTPError;