-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: It doesn't seem like octokit rest returns a RequestError
object
#266
Comments
I'm having the same issue, error handling is really underdocumented in octokit. import { RequestError } from "@octokit/request-error";
try {
// some octokit request
} catch (error) {
if (error instanceof RequestError) {
console.log("this never happens");
}
} Can the docs be made explicit what to do here? I'm assuming I'm importing the wrong
|
I had the same issue. I resolved it by importing everything from import { RequestError, Octokit } from 'octokit' Perhaps this library needs to re-export the Caveat: I'm a node noob so that might not be quite right |
Also I'd love to help contribute documentation or changes via PR, but since things aren't documented I'll need a project maintainer to weigh in here on the right changes to make! What's the best way to get some 👀 on this? |
The Feel free to test things out locally to see what works and come back with a PR. I don't understand myself why it doesn't match |
We catch all errors and wrap them in |
Using this in both CommonJS and ESM files gives the expected result:
We need more information about the environment you're running - |
I wonder if running in a monorepo via Turborepo where multiple sub-packages are compiled and imported could cause a mismatch in class/prototypes? |
What happened?
I have function which gets some repository details and does some stuff with it. It's enclosed in try catch block to handle different errors. Here is a simplified version of it
Although after running my code with non-existant owner and repo, this function always logs "non octokit error" instead of "octokit error"
However according to this discussion all the error objects should be an instance of
RequestError
: octokit/octokit.js#2039Versions
@octokit/rest: ^18.12.0
Node: v16.19.0
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: