summaryrefslogtreecommitdiff
path: root/load.c
diff options
context:
space:
mode:
Diffstat (limited to 'load.c')
-rw-r--r--load.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/load.c b/load.c
index cddd7255ac..67020a1ecd 100644
--- a/load.c
+++ b/load.c
@@ -495,7 +495,7 @@ rb_f_require_relative(VALUE obj, VALUE fname)
{
VALUE base = rb_current_realfilepath();
if (NIL_P(base)) {
- rb_raise(rb_eLoadError, "cannot infer basepath");
+ rb_loaderror("cannot infer basepath");
}
base = rb_file_dirname(base);
return rb_require_safe(rb_file_absolute_path(fname, base), rb_safe_level());
@@ -588,12 +588,13 @@ search_required(VALUE fname, volatile VALUE *path, int safe_level)
return type ? 's' : 'r';
}
+void rb_loaderror_with_path(VALUE path, const char *fmt, ...);
+
static void
load_failed(VALUE fname)
{
- VALUE mesg = rb_str_buf_new_cstr("cannot load such file -- ");
- rb_str_append(mesg, fname); /* should be ASCII compatible */
- rb_exc_raise(rb_exc_new3(rb_eLoadError, mesg));
+ rb_loaderror_with_path(fname, "cannot load such file -- %s", RSTRING_PTR(fname));
+ RB_GC_GUARD(fname);
}
static VALUE