Issue #11355 has been reported by Stefano Tortarolo.

----------------------------------------
Misc #11355: Exceptions inheriting from Timeout::Error should behave the same way
https://bugs.ruby-lang.org/issues/11355

* Author: Stefano Tortarolo
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
Bug #8730 addressed a common issue when using Timeout#timeout [*], but I think that the current behaviour is at the very least surprising.

Right now, exceptions provided to Timeout#timeout are rescuable from the inner block and that applies to Timeout::Error too.
The confusing aspect is that there's no way to provide a custom exception that inherits from Timeout::Error and make it not rescuable by the inner block (i.e., #9115).

Basically what I would expect is a way to provide a custom exception that'streated calling #catch on it in Timeout#timeout

~~~
#This could be applied to every exception that inherits from Timeout::Error
# but we need a different interface to provide it, in order to maintain thebehaviour that a provided exception is rescuable
bt = Error.catch(message, &bl)
~~~

I'm filing this as Misc and not Bug exactly because reading the code it's expected behaviour, so I'm mainly trying to foster a conversation about whether there's a nice way to support both scenarios.

[*] I don't speak Japanese and I cannot fully trust Google Translate, so forgive me if I lost some fundamental concepts in that thread.



-- 
https://bugs.ruby-lang.org/