[C exten] How to raise a Exception instance?

Hi, in Ruby land this is easy:

···

-----------------------------------------------------
  error = StandardError.new "my error message"

  raise error

  => StandardError: my error message
       (backtrace..)
-----------------------------------------------------

How to do the same at C level having a StandardError instance stored
within a VALUE error?

I've looked for the definition of "raise" in Ruby 1.9.3 sources. I
know that using rb_funcall for Kernel module and method "raise" could
work, but maybe there is something a bit better.

Thanks a lot.

--
Iñaki Baz Castillo
<ibc@aliax.net>

Iñaki Baz Castillo писал 12.05.2012 18:30:

Hi, in Ruby land this is easy:

-----------------------------------------------------
  error = StandardError.new "my error message"

  raise error

  => StandardError: my error message
       (backtrace..)
-----------------------------------------------------

How to do the same at C level having a StandardError instance stored
within a VALUE error?

I've looked for the definition of "raise" in Ruby 1.9.3 sources. I
know that using rb_funcall for Kernel module and method "raise" could
work, but maybe there is something a bit better.

Thanks a lot.

Try rb_exc_raise:
   http://rxr.whitequark.org/mri/source/eval.c#457

···

--
   WBR, Peter Zotov.

I checked it, but it creates a new exception and it not valid for me.
I've a Hash with instances of custom exceptions. I access them from C
land and want to raise exactly one of those instances (and not
creating a new instance).

Anyhow I've already it working by using rb_funcall for invoking
Kernel.raise(my_error) in C.

Thanks a lot.

···

2012/5/12 Peter Zotov <whitequark@whitequark.org>:

Try rb_exc_raise:
http://rxr.whitequark.org/mri/source/eval.c#457

--
Iñaki Baz Castillo
<ibc@aliax.net>