문제

If you write a ruby method as a function in C that uses rb_raise, the part of the function after the call will not get excecuted and the program will stop and you will think that rb_raise used exit(). But if you rescue the exception in ruby, like:

begin
  method_that_raises_an_exception
rescue
end
puts 'You wil still get here.'

The ruby code will go on, but your function will stop excecuting. How does rb_raise make this happen?

도움이 되었습니까?

해결책

Presumably it uses setjmp (before the method is called) and longjmp (in rb_raise).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top