- Notifications
You must be signed in to change notification settings - Fork15
Error class for Octokit request errors
License
NotificationsYou must be signed in to change notification settings
octokit/request-error.js
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Error class for Octokit request errors
| Browsers | Load@octokit/request-error directly fromesm.sh<scripttype="module">import{RequestError}from"https://esm.sh/@octokit/request-error";</script> |
|---|---|
| Node | Install with import{RequestError}from"@octokit/request-error"; |
Important
As we useconditional exports, you will need to adapt yourtsconfig.json by setting"moduleResolution": "node16", "module": "node16".
See the TypeScript docs onpackage.json "exports".
See thishelpful guide on transitioning to ESM from@sindresorhus
consterror=newRequestError("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;// Oopserror.status;// 500error.request;// { method, url, headers, body }error.response;// { url, status, headers, data }
try{// your code here that sends at least one Octokit requestawaitoctokit.request("GET /");}catch(error){// Octokit errors always have a `error.status` property which is the http response codeif(error.status){// handle Octokit error}else{// handle all other errorsthrowerror;}}
About
Error class for Octokit request errors
Topics
Resources
License
Code of conduct
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.