-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Error inheritance is not working #2956
Comments
And will probably not work any time soon i'm afraid: #2359 😔 |
BTW, you can make it work pretty easily with |
Thanks @epidemian :p. |
@Nami-Doc @epidemian I think this might need some more attention and possibly some documentation. The code you suggest is probably not what most people want out of an error subclass…although it does satisfy the |
@matthewwithanm, you're right! It seems calling the super Would this be a correct minimal error subclass?: class MyError extends Error
name: 'MyError'
constructor: (@message) -> (it seems it does all that's expected) Damn JS native constructors are weird! Thanks for the feedback! I don't know where this should be documented, or even if it should be documented at all in the Coffee project (isn't it a JavaScript issue?). Maybe it could be included as a common gotcha like "why can't i subclass native objects?" or something on that vein (though i don't know how common that gotcha really is). |
That's what I'm using. It's not really future proof (future browsers may, and apparently FF already does, accept other arguments that aren't part of the current standard), but I think it covers all real-world use-cases. This is totally a JS issue but (IMO at least) it should be documented somewhere with the project—though this thread is already an improvement over links to the #2359 discussion (which is rather lengthy, technical, and currently doesn't have a real solution). Alternatively, we could post a new SO question (or update your original) with the proper pattern…but that's still only really useful to those who already recognize that it is a problem (as opposed to a "gotchas" note or a quick sentence warning about extending built-ins when introducing classes). Ah, JS (: |
The text was updated successfully, but these errors were encountered: