summaryrefslogtreecommitdiff
path: root/eval_error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-26 16:13:21 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-26 16:13:21 +0000
commitc56b3d14181d0627cd044a21906fdb191a7f83f7 (patch)
tree092efbf5865ff30d7722cbc151d5aea97408ddb9 /eval_error.c
parent61fd9777984b8be47ed95c234e1357a19c6c4980 (diff)
eval_error.c: rb_print_inaccessible
* eval_error.c (rb_print_inaccessible): exract from mnew_from_me() in proc.c git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval_error.c')
-rw-r--r--eval_error.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/eval_error.c b/eval_error.c
index 401eba8..8bcbd39 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)
{