Use more verbose status in error messages
of `system` with `exception: true` like `Process::Status#inspect` [Feature #14386] [ruby-core:85013] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
49e801c1c7
commit
1659a1660c
@ -548,7 +548,8 @@ pst_pid(VALUE st)
|
|||||||
static void
|
static void
|
||||||
pst_message(VALUE str, rb_pid_t pid, int status)
|
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)) {
|
if (WIFSTOPPED(status)) {
|
||||||
int stopsig = WSTOPSIG(status);
|
int stopsig = WSTOPSIG(status);
|
||||||
const char *signame = ruby_signal_name(stopsig);
|
const char *signame = ruby_signal_name(stopsig);
|
||||||
@ -4090,8 +4091,10 @@ rb_f_system(int argc, VALUE *argv)
|
|||||||
status = PST2INT(rb_last_status_get());
|
status = PST2INT(rb_last_status_get());
|
||||||
if (status == EXIT_SUCCESS) return Qtrue;
|
if (status == EXIT_SUCCESS) return Qtrue;
|
||||||
if (eargp->exception) {
|
if (eargp->exception) {
|
||||||
rb_raise(rb_eRuntimeError, "Command failed with status (%d): %s",
|
VALUE str = rb_str_buf_new(0);
|
||||||
WEXITSTATUS(status), RSTRING_PTR(eargp->invoke.sh.shell_script));
|
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 {
|
else {
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user