diff options
Diffstat (limited to 'eval_error.c')
-rw-r--r-- | eval_error.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/eval_error.c b/eval_error.c index 401eba8c54..8bcbd39c5e 100644 --- a/eval_error.c +++ b/eval_error.c @@ -208,8 +208,8 @@ ruby_error_print(void) error_print(); } -void -rb_print_undef(VALUE klass, ID id, int scope) +static const char * +method_scope_name(int scope) { const char *v; @@ -219,6 +219,13 @@ rb_print_undef(VALUE klass, ID id, int scope) case NOEX_PRIVATE: v = " private"; break; case NOEX_PROTECTED: v = " protected"; break; } + return v; +} + +void +rb_print_undef(VALUE klass, ID id, int scope) +{ + const char *v = method_scope_name(scope); rb_name_error(id, "undefined%s method `%"PRIsVALUE"' for %s `%"PRIsVALUE"'", v, QUOTE_ID(id), (RB_TYPE_P(klass, T_MODULE)) ? "module" : "class", @@ -234,6 +241,17 @@ rb_print_undef_str(VALUE klass, VALUE name) rb_class_name(klass)); } +void +rb_print_inaccessible(VALUE klass, ID id, int scope) +{ + const char *v = method_scope_name(scope); + rb_name_error(id, "method `%s' for %s `% "PRIsVALUE"' is %s", + rb_id2name(id), + (RB_TYPE_P(klass, T_MODULE)) ? "module" : "class", + rb_class_name(klass), + v); +} + static int sysexit_status(VALUE err) { |