From d488b7de1df729aa6fbc3b1107d9f5ad3be5235a Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Thu, 8 May 2014 17:24:14 -0300 Subject: API: Extract error boilerplate into a macro --- src/api/helpers.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/api/helpers.c') diff --git a/src/api/helpers.c b/src/api/helpers.c index 425da998bc..9f41e55d39 100644 --- a/src/api/helpers.c +++ b/src/api/helpers.c @@ -21,15 +21,12 @@ bool try_end(Error *err) did_emsg = false; if (got_int) { - const char msg[] = "Keyboard interrupt"; - if (did_throw) { // If we got an interrupt, discard the current exception discard_current_exception(); } - strncpy(err->msg, msg, sizeof(err->msg)); - err->set = true; + set_api_error("Keyboard interrupt", err); got_int = false; } else if (msg_list != NULL && *msg_list != NULL) { int should_free; @@ -45,8 +42,7 @@ bool try_end(Error *err) free(msg); } } else if (did_throw) { - strncpy(err->msg, (char *)current_exception->value, sizeof(err->msg)); - err->set = true; + set_api_error((char *)current_exception->value, err); } return err->set; -- cgit