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
Change NotImplementedError to something else #2067
Comments
Wow, I had no idea about that! I must have gotten confused from Python's NotImplementedError! I think a good replacement would be something like |
Hello, I would like to work on this issue :) |
@rahulbajaj0509 Did you get anywhere with this one? If not I can take a look. |
I don't think this was ever worked on. |
@jbryant92 @rmosolgo hey, I am sorry I was not able to work on this one. Please feel free to take this over. |
Hello all, |
Perhaps I'm misunderstanding something, but I'd like to suggest that this gem move away from using
NotImplementedError
.Take a look at the docs: http://ruby-doc.org/core-2.6/NotImplementedError.html. At issue is the OS and particular ruby implementation. You're supposed to raise that error if the current ruby or OS can't do something you need it to do. NOT if a subclass hasn't implemented an expected method.
Why is this a problem? Because
NotImplementedError
does not subclassStandardError
, which is surprising. It subclassesScriptError
. Thus, normal rescuing (either explicitly or implicitly rescuingStandardError
) won't work, and we end up rescuing things we honestly shouldn't.Thus, I'd propose that all usage of
NotImplementedError
be changed to something else, or perhaps simply removed, if that would cause a semantically meaningful error to be raised (like aNoMethodError
). At the very least, use something subclassed under a module, so it can be rescued specifically. And subclass that module underStandardError
, so that rescuing allStandardError
will work as expected, or even better,NoMethodError
, since this is really a particular type ofNoMethodError
.See discussion at:
http://chrisstump.online/2016/03/23/stop-abusing-notimplementederror/
https://www.reddit.com/r/ruby/comments/4cal7v/please_stop_abusing_notimplementederror/
https://airbrake.io/blog/ruby-exception-handling/notimplementederror
rubocop/ruby-style-guide#458
https://stackoverflow.com/questions/13668068/how-to-signal-not-implemented-yet
The text was updated successfully, but these errors were encountered: