concurrent-ruby
concurrent-ruby copied to clipboard
Exception catching
C-R should unify on what exceptions to catch. Discussed in #507
The Ruby exception hierarchy puts the exceptions from which we are picking on the same level so I think it's valid to put together a list of exceptions which should be caught because otherwise they would break the abstraction or would be silently ignored which is highly undesirable.
The list of exceptions was not put together carefully though, and it should be discussed further.
The hierarchy:
Exception
NoMemoryError
ScriptError
LoadError
NotImplementedError
SyntaxError
SecurityError
SignalException
Interrupt
StandardError
# ...
SystemExit
SystemStackError
fatal
I think that only unrecoverable exceptions (fatal, NoMemoryError) and SystemExit should not be caught, rest makes sense to report to the user as a failed future. SignalException afaik can be ignored since it's raised only on main thread.
"puts the exceptions from which we are picking on the same level..."
Yes, so treating them all identically is reasonable.
"only unrecoverable exceptions (fatal, NoMemoryError)..."
This is a subjective choice. It is impossible for us to know a priori that NoMemoryError
is unrecoverable, so grouping it with fatal
is an arbitrary choice. It is impossible in Ruby to rescue fatal
but it is possible to rescue all the others. If the Ruby core team considered NoMemoryError
to be unrecoverable they would have just used fatal
. But they didn't and we should be consistent with their choices.