-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
discussion: error classes #4067
Comments
Lowercase like I prefer |
In another context: Trying to import a CJS module using
hard to debug. Source: import { createRequire } from "https://deno.land/std/node/module.ts";
const selfPath = window.unescape(import.meta.url.substring(7));
const require_ = createRequire(selfPath); Edit: Any tips on how to debug that? |
I also like Deno.errors.xxxxx better. I don't mind extra typing for clarity and consistancy. |
@evenstensberg You should pin your dependency, e.g. |
At first I thought |
Actually, would it be so bad to make them all top-level e.g. While it looks worse, it feels better to type somehow... you're trying to differentiate between error kinds, having to write That's what's nice about the |
Or we could use assert(e instanceof Deno.errors.PermissionDenied); I really hate such long APIs... but maybe it's okay. |
Only problem is the name of the class would be
Instead of:
Which is more aligned to other JavaScript errors. |
We recently changed the mechanism for exception handling (see #3936 )
Deno ops return an error object with a code which can be accessed via "err.kind"
That is still the case but now we've introduced classes for each of the Deno error types, so that exceptions can be checked using
instanceof
My question is if we should use
Deno.err.PermissionDenied
? orDeno.Err.PermissionDenied
? OrDeno.Errors.PermissionDenied
? orDeno.errors.PermissionDenied
?Personally I'm in favor of
Deno.err.PermissionDenied
because it's the least amount of typing.The text was updated successfully, but these errors were encountered: