[前][次][番号順一覧][スレッド一覧]

ruby-changes:50040

From: kazu <ko1@a...>
Date: Fri, 2 Feb 2018 20:03:28 +0900 (JST)
Subject: [ruby-changes:50040] kazu:r62158 (trunk): Use more verbose status in error messages

kazu	2018-02-02 20:03:22 +0900 (Fri, 02 Feb 2018)

  New Revision: 62158

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62158

  Log:
    Use more verbose status in error messages
    
    of `system` with `exception: true` like `Process::Status#inspect`
    [Feature #14386] [ruby-core:85013]

  Modified files:
    trunk/process.c
Index: process.c
===================================================================
--- process.c	(revision 62157)
+++ process.c	(revision 62158)
@@ -548,7 +548,8 @@ pst_pid(VALUE st) https://github.com/ruby/ruby/blob/trunk/process.c#L548
 static void
 pst_message(VALUE str, rb_pid_t pid, int status)
 {
-    rb_str_catf(str, "pid %ld", (long)pid);
+    if (pid != (rb_pid_t)-1)
+        rb_str_catf(str, "pid %ld", (long)pid);
     if (WIFSTOPPED(status)) {
 	int stopsig = WSTOPSIG(status);
 	const char *signame = ruby_signal_name(stopsig);
@@ -4090,8 +4091,10 @@ rb_f_system(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L4091
     status = PST2INT(rb_last_status_get());
     if (status == EXIT_SUCCESS) return Qtrue;
     if (eargp->exception) {
-        rb_raise(rb_eRuntimeError, "Command failed with status (%d): %s",
-                 WEXITSTATUS(status), RSTRING_PTR(eargp->invoke.sh.shell_script));
+        VALUE str = rb_str_buf_new(0);
+        pst_message(str, (rb_pid_t)-1, status);
+        rb_raise(rb_eRuntimeError, "Command failed with%"PRIsVALUE": %s",
+                 str, RSTRING_PTR(eargp->invoke.sh.shell_script));
     }
     else {
         return Qfalse;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]