Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ext/mini_racer_extension/mini_racer_extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,8 +1005,8 @@ static void handle_exception(VALUE e)

if (NIL_P(e))
return;
StringValue(e);
s = RSTRING_PTR(e);
e = StringValue(e);
s = StringValueCStr(e);
switch (*s) {
case NO_ERROR:
return;
Expand All @@ -1028,7 +1028,7 @@ static void handle_exception(VALUE e)
default:
rb_raise(internal_error, "bad error class %02x", *s);
}
rb_raise(klass, "%s", s+1);
rb_enc_raise(rb_enc_get(e), klass, "%s", s+1);
}

static VALUE context_alloc(VALUE klass)
Expand Down
11 changes: 11 additions & 0 deletions test/mini_racer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1172,4 +1172,15 @@ def test_large_integer
assert_equal(types, %w[number bigint number bigint])
end
end

def test_exception_message_encoding
e = nil
begin
MiniRacer::Context.new.eval("throw Error('ä')")
rescue MiniRacer::RuntimeError => e_
e = e_
end
assert e
assert_equal(e.message.encoding.to_s, "UTF-8")
end
end
Loading