mirror of
https://github.com/ASzc/change-string-case-action.git
synced 2024-11-23 20:53:50 +08:00
.. | ||
dist-node | ||
dist-src | ||
dist-types | ||
dist-web | ||
LICENSE | ||
package.json | ||
README.md |
http-error.js
Error class for Octokit request errors
Usage
Browsers |
Load @octokit/request-error directly from esm.sh
|
---|---|
Node |
Install with
|
const error = new RequestError("Oops", 500, {
request: {
method: "POST",
url: "https://api.github.com/foo",
body: {
bar: "baz",
},
headers: {
authorization: "token secret123",
},
},
response: {
status: 500,
url: "https://api.github.com/foo",
headers: {
"x-github-request-id": "1:2:3:4",
},
data: {
foo: "bar",
},
},
});
error.message; // Oops
error.status; // 500
error.request; // { method, url, headers, body }
error.response; // { url, status, headers, data }
Usage with Octokit
try {
// your code here that sends at least one Octokit request
await octokit.request("GET /");
} catch (error) {
// Octokit errors always have a `error.status` property which is the http response code
if (error.status) {
// handle Octokit error
} else {
// handle all other errors
throw error;
}
}