mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Add NameError#name. Fix NameError.new and NameError.initialize. Enable 2nd argument for NameError.new in C API.
This commit is contained in:
@@ -38,6 +38,16 @@ end
|
||||
|
||||
# ISO 15.2.31
|
||||
class NameError < StandardError
|
||||
attr_accessor :name
|
||||
|
||||
def new(message="NameError", name=nil)
|
||||
initialize(message, name)
|
||||
end
|
||||
|
||||
def initialize(message=nil, name=nil)
|
||||
@name = name
|
||||
super(message)
|
||||
end
|
||||
end
|
||||
|
||||
# ISO 15.2.32
|
||||
|
||||
+2
-2
@@ -306,8 +306,8 @@ mrb_name_error(mrb_state *mrb, mrb_sym id, const char *fmt, ...)
|
||||
argv[0] = mrb_vformat(mrb, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
argv[1] = mrb_symbol_value(id); /* ignore now */
|
||||
exc = mrb_class_new_instance(mrb, 1, argv, E_NAME_ERROR);
|
||||
argv[1] = mrb_symbol_value(id);
|
||||
exc = mrb_class_new_instance(mrb, 2, argv, E_NAME_ERROR);
|
||||
mrb_exc_raise(mrb, exc);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user