ruby-changes:60786
From: Nobuyoshi <ko1@a...>
Date: Wed, 15 Apr 2020 22:08:42 +0900 (JST)
Subject: [ruby-changes:60786] d72fd1e45b (master): Added rb_syserr_new_path
https://git.ruby-lang.org/ruby.git/commit/?id=d72fd1e45b From d72fd1e45b192ab507f8170ceec1328c2aae7bb1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 15 Apr 2020 00:59:23 +0900 Subject: Added rb_syserr_new_path Similar to rb_syserr_fail_path, but just returns the created exception instance instead of raising it. diff --git a/error.c b/error.c index 7e4fb7b..d6be8d8 100644 --- a/error.c +++ b/error.c @@ -2830,6 +2830,12 @@ rb_sys_fail_path_in(const char *func_name, VALUE path) https://github.com/ruby/ruby/blob/trunk/error.c#L2830 void rb_syserr_fail_path_in(const char *func_name, int n, VALUE path) { + rb_exc_raise(rb_syserr_new_path_in(func_name, n, path)); +} + +VALUE +rb_syserr_new_path_in(const char *func_name, int n, VALUE path) +{ VALUE args[2]; if (!path) path = Qnil; @@ -2841,7 +2847,7 @@ rb_syserr_fail_path_in(const char *func_name, int n, VALUE path) https://github.com/ruby/ruby/blob/trunk/error.c#L2847 } args[0] = path; args[1] = rb_str_new_cstr(func_name); - rb_exc_raise(rb_class_new_instance(2, args, get_syserr(n))); + return rb_class_new_instance(2, args, get_syserr(n)); } #endif diff --git a/internal/error.h b/internal/error.h index 5a9b6cd..b6fd25b 100644 --- a/internal/error.h +++ b/internal/error.h @@ -32,9 +32,11 @@ https://github.com/ruby/ruby/blob/trunk/internal/error.h#L32 #ifdef RUBY_FUNCTION_NAME_STRING # define rb_sys_fail_path(path) rb_sys_fail_path_in(RUBY_FUNCTION_NAME_STRING, path) # define rb_syserr_fail_path(err, path) rb_syserr_fail_path_in(RUBY_FUNCTION_NAME_STRING, (err), (path)) +# define rb_syserr_new_path(err, path) rb_syserr_new_path_in(RUBY_FUNCTION_NAME_STRING, (err), (path)) #else # define rb_sys_fail_path(path) rb_sys_fail_str(path) # define rb_syserr_fail_path(err, path) rb_syserr_fail_str((err), (path)) +# define rb_syserr_new_path(err, path) rb_syserr_new_str((err), (path)) #endif /* error.c */ @@ -79,6 +81,7 @@ int rb_bug_reporter_add(void (*func)(FILE *, void *), void *data); https://github.com/ruby/ruby/blob/trunk/internal/error.h#L81 #ifdef RUBY_FUNCTION_NAME_STRING NORETURN(void rb_sys_fail_path_in(const char *func_name, VALUE path)); NORETURN(void rb_syserr_fail_path_in(const char *func_name, int err, VALUE path)); +VALUE rb_syserr_new_path_in(const char *func_name, int n, VALUE path); #endif RUBY_SYMBOL_EXPORT_END -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/