mirror of
https://github.com/github/codeql-action.git
synced 2025-12-27 01:30:10 +08:00
I explicitly had to downgrade "@octokit/plugin-retry" to "^6.0.0". Other dependencies were upgraded.
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
class RequestError extends Error {
|
|
name;
|
|
/**
|
|
* http status code
|
|
*/
|
|
status;
|
|
/**
|
|
* Request options that lead to the error.
|
|
*/
|
|
request;
|
|
/**
|
|
* Response object if a response was received
|
|
*/
|
|
response;
|
|
constructor(message, statusCode, options) {
|
|
super(message);
|
|
this.name = "HttpError";
|
|
this.status = Number.parseInt(statusCode);
|
|
if (Number.isNaN(this.status)) {
|
|
this.status = 0;
|
|
}
|
|
if ("response" in options) {
|
|
this.response = options.response;
|
|
}
|
|
const requestCopy = Object.assign({}, options.request);
|
|
if (options.request.headers.authorization) {
|
|
requestCopy.headers = Object.assign({}, options.request.headers, {
|
|
authorization: options.request.headers.authorization.replace(
|
|
/(?<! ) .*$/,
|
|
" [REDACTED]"
|
|
)
|
|
});
|
|
}
|
|
requestCopy.url = requestCopy.url.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]").replace(/\baccess_token=\w+/g, "access_token=[REDACTED]");
|
|
this.request = requestCopy;
|
|
}
|
|
}
|
|
export {
|
|
RequestError
|
|
};
|