How does ruby's rb_raise stop the execution of the c function calling it?

Posted by Adrian on Stack Overflow See other posts from Stack Overflow or by Adrian
Published on 2010-03-29T03:00:22Z Indexed on 2010/03/29 3:03 UTC
Read the original article Hit count: 407

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about ruby

Related posts about errors