From 6d04ff98c4bfc21ad3fa779237a16ba760080fac Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sun, 19 Apr 2020 16:31:45 -0400 Subject: Better reporting when a package does not exist * Add additional errors * Fix user_input function missing an error return value * spmbuild sources a temporary file instead of output from a sub-shell * Fix indentation problem * A reason can be attached to spmerrno using spmerrno_cause() --- lib/error_handler.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/error_handler.c') diff --git a/lib/error_handler.c b/lib/error_handler.c index baf56b4..292fa6f 100644 --- a/lib/error_handler.c +++ b/lib/error_handler.c @@ -2,7 +2,13 @@ int spmerrno = 0; static char spmerrbuf[255]; +static char spmerrbuf_reason[255]; +void spmerrno_cause(const char *reason) { + char *buf = spmerrbuf_reason; + sprintf(buf, " (%s)", reason); + return; +} /** * * @param code @@ -18,6 +24,10 @@ char *spm_strerror(int code) { } else { strcpy(buf, SPM_ERR_STRING[SPM_ERR_INDEX(code)]); } + + if (strlen(spmerrbuf_reason)) { + strcat(buf, spmerrbuf_reason); + } return buf; } -- cgit