@octokit/request-error
Advanced tools
Comparing version 3.0.2 to 3.0.3
@@ -15,29 +15,22 @@ 'use strict'; | ||
*/ | ||
class RequestError extends Error { | ||
constructor(message, statusCode, options) { | ||
super(message); // Maintains proper stack trace (only available on V8) | ||
super(message); | ||
// Maintains proper stack trace (only available on V8) | ||
/* istanbul ignore next */ | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, this.constructor); | ||
} | ||
this.name = "HttpError"; | ||
this.status = statusCode; | ||
let headers; | ||
if ("headers" in options && typeof options.headers !== "undefined") { | ||
headers = options.headers; | ||
} | ||
if ("response" in options) { | ||
this.response = options.response; | ||
headers = options.response.headers; | ||
} // redact request credentials without mutating original request options | ||
} | ||
// redact request credentials without mutating original request options | ||
const requestCopy = Object.assign({}, options.request); | ||
if (options.request.headers.authorization) { | ||
@@ -48,10 +41,11 @@ requestCopy.headers = Object.assign({}, options.request.headers, { | ||
} | ||
requestCopy.url = requestCopy.url // client_id & client_secret can be passed as URL query parameters to increase rate limit | ||
requestCopy.url = requestCopy.url | ||
// client_id & client_secret can be passed as URL query parameters to increase rate limit | ||
// see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications | ||
.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]") // OAuth tokens can be passed as URL query parameters, although it is not recommended | ||
.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]") | ||
// OAuth tokens can be passed as URL query parameters, although it is not recommended | ||
// see https://developer.github.com/v3/#oauth2-token-sent-in-a-header | ||
.replace(/\baccess_token=\w+/g, "access_token=[REDACTED]"); | ||
this.request = requestCopy; // deprecations | ||
this.request = requestCopy; | ||
// deprecations | ||
Object.defineProperty(this, "code", { | ||
@@ -62,3 +56,2 @@ get() { | ||
} | ||
}); | ||
@@ -70,6 +63,4 @@ Object.defineProperty(this, "headers", { | ||
} | ||
}); | ||
} | ||
} | ||
@@ -76,0 +67,0 @@ |
import { RequestOptions, ResponseHeaders, OctokitResponse } from "@octokit/types"; | ||
export declare type RequestErrorOptions = { | ||
export type RequestErrorOptions = { | ||
/** @deprecated set `response` instead */ | ||
@@ -4,0 +4,0 @@ headers?: ResponseHeaders; |
{ | ||
"name": "@octokit/request-error", | ||
"description": "Error class for Octokit request errors", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"license": "MIT", | ||
@@ -24,3 +24,3 @@ "files": [ | ||
"dependencies": { | ||
"@octokit/types": "^8.0.0", | ||
"@octokit/types": "^9.0.0", | ||
"deprecation": "^2.0.0", | ||
@@ -36,7 +36,7 @@ "once": "^1.4.0" | ||
"@types/jest": "^29.0.0", | ||
"@types/node": "^16.0.0", | ||
"@types/node": "^18.0.0", | ||
"@types/once": "^1.4.0", | ||
"jest": "^29.0.0", | ||
"pika-plugin-unpkg-field": "^1.1.0", | ||
"prettier": "2.7.1", | ||
"prettier": "2.8.3", | ||
"ts-jest": "^29.0.0", | ||
@@ -43,0 +43,0 @@ "typescript": "^4.0.0" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
215
21698
+ Added@octokit/openapi-types@18.1.1(transitive)
+ Added@octokit/types@9.3.2(transitive)
- Removed@octokit/openapi-types@14.0.0(transitive)
- Removed@octokit/types@8.2.1(transitive)
Updated@octokit/types@^9.0.0