Skip to content

Commit

Permalink
Improve error when failing to spawn process
Browse files Browse the repository at this point in the history
for example, it used to be "no such file or directory", but
now it's "Failed to spawn process blorp: no such file
or directory (error code -2)"

Especially when the text is all the context a user has to
go on, it can be very helpful to have the info that it was
an error during process spawn, and what the program was.
  • Loading branch information
timo committed Jul 15, 2019
1 parent f1b26bb commit 93739d5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/io/procops.c
Expand Up @@ -733,9 +733,18 @@ static void spawn_setup(MVMThreadContext *tc, uv_loop_t *loop, MVMObject *async_
MVMObject *msg_box = NULL;
si->state = STATE_DONE;
MVMROOT2(tc, async_task, msg_box, {
char *error_str = MVM_malloc(128);
MVMObject *error_cb;
MVMString *msg_str = MVM_string_ascii_decode_nt(tc,
tc->instance->VMString, uv_strerror(spawn_result));
MVMString *msg_str;

snprintf(error_str, 127, "Failed to spawn process %s: %s (error code %d)",
si->prog, uv_strerror(spawn_result), spawn_result);

msg_str = MVM_string_ascii_decode_nt(tc,
tc->instance->VMString, error_str);

MVM_free(error_str);

msg_box = MVM_repr_box_str(tc,
tc->instance->boot_types.BOOTStr, msg_str);

Expand Down

0 comments on commit 93739d5

Please sign in to comment.