You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{RequestError}from"octokit";try{// your code here that sends at least one Octokit requestawaitoctokit.request("GET /");}catch(error){// Octokit errors are instances of RequestError, so they always have an `error.status` property containing the HTTP response code.if(errorinstanceofRequestError){// handle Octokit error// error.message; // Oops// error.status; // 500// error.request; // { method, url, headers, body }// error.response; // { url, status, headers, data }}else{// handle all other errorsthrowerror;}}
Scripts don't have access to the RequestError class, making error handling a pain.
Describe the solution you'd like
Expose RequestError to the script.
Describe alternatives you've considered
You can skip the instanceof check and access the attribute directly (e.g. error.status) but this is approach is very imprecise and error-prone.
Activity