Can you provide a link to the transitional exceptions page?
In any case, you can create a new exception at any time, and it's usually good to do so that you can pass additional information about the failure. This is especially good when you have an allow level exception and want to make it more meaningful to the user.
Throw / Catch in Ruby is indeed a kind of non-local transition, such as setjmp / longjmp in C, but it's better to behave. You will use it anytime you want to broadcast execution in long ways.
, goto, . , , - , , , , , , .
, , . 97 , , .... , , . 157 .
, " " , , , , BOFH . , , , . ?
. :
class RetryException < RuntimeError
attr: ok_to_retry
def initialize(ok_to_retry)
@ok_to_retry
end
end
, - ,
raise RetryException.new(true), "transient read error"
- RuntimeError , , , , ", ".
NOw, Ruby: . , - , :
begin
do_something()
rescue RetryException => detail
if detail.ok_to_retry
retry
end
raise
end