diff options
| -rw-r--r-- | mrblib/error.rb | 10 | ||||
| -rw-r--r-- | src/error.c | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/mrblib/error.rb b/mrblib/error.rb index 32b50da92..9e5a3daeb 100644 --- a/mrblib/error.rb +++ b/mrblib/error.rb @@ -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 diff --git a/src/error.c b/src/error.c index 5f1476115..522901ff7 100644 --- a/src/error.c +++ b/src/error.c @@ -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); } |
