Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions lib/http-error.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
'use strict'

const STATUS_CODES = {
304: 'Not Modified', // See PR #673 (https://github.com/octokit/rest.js/pull/673)
400: 'Bad Request',
404: 'Not Found',
500: 'Internal Server Error',
504: 'Gateway Timeout'
}

module.exports = class HttpError extends Error {
constructor (message, code, headers) {
constructor (message, code) {
super(message)
// Maintains proper stack trace for where our error was thrown (only available on V8)
/* istanbul ignore else */

// Maintains proper stack trace (only available on V8)
/* istanbul ignore next */
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor)
}

this.name = 'HttpError'
this.code = code
this.status = STATUS_CODES[code]
this.headers = headers
}
}