summaryrefslogtreecommitdiff
path: root/ext/-test-/exception/enc_raise.c
blob: 68d7b4ebc1784c908f4d860817e101c310f8ae86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <ruby.h>
#include <ruby/encoding.h>

static VALUE
enc_raise(VALUE exc, VALUE encoding, VALUE mesg)
{
    rb_enc_raise(rb_to_encoding(encoding), exc, "%s", StringValueCStr(mesg));
    UNREACHABLE_RETURN(Qnil);
}

void
Init_enc_raise(VALUE klass)
{
    rb_define_module_function(klass, "enc_raise", enc_raise, 2);
}