Is nested launch / rescue / safe?

It seems good to me, and I can’t find the documentation that says otherwise, but I would like it to be checked. I have a piece of code that for some reason can fail, guarantee protection after it if it fails, and then execute some code no matter what happens. It seems like a nested begin / make block is required. It's right? (There is no real salvation here, only this type of block.)

The code looks like this:

  begin
    # save default state
    begin
      # save current state
      # set state for this snippet
      # snippet
    ensure
      # return current state or default if none
    end
  ensure
    # schedule next execution of this code, always.
  end
+4
source share
1 answer

This is the right approach. Nesting is often necessary, sometimes in the same method as you are here, and sometimes through the call stack.

+3

Source: https://habr.com/ru/post/1610479/


All Articles