I'm not entirely sure how this helps me... I need to call ruby code from 
C, and have some error handling/protection.

For example, after initializing mruby, I try to load a ruby file (which 
BTW tries to 'require' another file, which can be found on $:). I dunno 
what's happening, but my app fails with an assertion:

src\debug.c:135, irep->filename

I have no idea where to get a hold on this error (or, for that matter, 
any other error/exception I might encounter in ruby code called from C).

PS.: the mruby-require mrbgem is installed

On 2015.04.04. 08:52, Carlo E. Prelz wrote:
> 	Subject: Re: embeddig ruby in a C application
> 	Date: ven 03 apr 15 05:18:52 +0200
>
> Quoting mortee (mortee.lists / kavemalna.hu):
>
>> Well, one thing I can't seem to figure out. What's the Mruby equivalent of
>> rb_protect()?
> I never happened to use that specific function in MRI/C. When I
> recently needed to call Ruby code from C in Mruby, I passed to a C
> method a block object like this:
>
> ob.meth(arg1,arg2) do |para|
>    do_something_with(para)
>    do_something_else
>    ...
>    ...
> end
>
> and in meth I would obtain the block in mrb_get_args with something
> like:
>
> mrb_get_args(mrb,"ii&",&s->arg1,&s->arg2,&s->blk);
>
> where arg1, arg2 and blk are defined in the C-structure associated
> with the object as follows:
>
> int arg1,arg2;
> mrb_value blk;
>
> Then, very important, to avoid the block being reaped by the GC,  I
> would assign it to a Ruby method variable with something like this:
>
> mrb_funcall(mrb,self,"instance_variable_set",2,mrb_symbol_value(mrb_intern_lit(mrb,"@blk")),s->blk);
>     
> At that point, when I needed to execute the Ruby code (from another
> C-coded method) I would call something like this:
>
> mrb_yield(mrb,s->blk,[whatever ruby object you want to appear as 'para']);
>
> Note that I have done this only once, and it required me quite a lot
> of research and experimenting. But it nicely solves the problem I
> needed to solve. YMMV
>
> Carlo
>