summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-10-25 17:45:54 -0400
committermidipix <writeonce@midipix.org>2016-11-10 23:35:55 -0500
commit79872959f5ff19b8c046eab6ecaae3b928ea9568 (patch)
treebced4ed7ac1acaa5e23e01d08bfacb2229c45fcf
parent09d2c02422490fa6d742547433f658145c2faed3 (diff)
downloadperk-79872959f5ff19b8c046eab6ecaae3b928ea9568.tar.bz2
perk-79872959f5ff19b8c046eab6ecaae3b928ea9568.tar.xz
output: pe_output_error_record(): output unit information.
-rw-r--r--src/output/pe_output_error.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/output/pe_output_error.c b/src/output/pe_output_error.c
index c08a7d5..e644fee 100644
--- a/src/output/pe_output_error.c
+++ b/src/output/pe_output_error.c
@@ -13,6 +13,7 @@
static const char aclr_reset[] = "\x1b[0m";
static const char aclr_bold[] = "\x1b[1m";
+static const char aclr_red[] = "\x1b[31m";
static const char aclr_green[] = "\x1b[32m";
static const char aclr_blue[] = "\x1b[34m";
static const char aclr_magenta[] = "\x1b[35m";
@@ -70,8 +71,19 @@ static int pe_output_error_record_plain(
const struct pe_driver_ctx * dctx,
const struct pe_error_info * erri)
{
+ const char * epath;
const char * errdesc = pe_output_strerror(erri);
+ epath = erri->euctx
+ ? *erri->euctx->path
+ : erri->eunit;
+
+ if (epath && !(erri->eflags & PERK_ERROR_NESTED))
+ if (fprintf(stderr,"%s: [while opening] '%s':\n",
+ dctx->program,
+ epath) < 0)
+ return -1;
+
if (fprintf(stderr,"%s: %s %s(), line %d%s%s.\n",
dctx->program,
pe_output_error_header(erri),
@@ -88,8 +100,30 @@ static int pe_output_error_record_annotated(
const struct pe_driver_ctx * dctx,
const struct pe_error_info * erri)
{
+ const char * epath;
const char * errdesc = pe_output_strerror(erri);
+ epath = erri->euctx
+ ? *erri->euctx->path
+ : erri->eunit;
+
+ if (epath && !(erri->eflags & PERK_ERROR_NESTED))
+ if (fprintf(
+ stderr,
+ "%s%s%s:%s %s[while opening]%s %s%s'%s'%s:\n",
+
+ aclr_bold,aclr_magenta,
+ dctx->program,
+ aclr_reset,
+
+ aclr_bold,
+ aclr_reset,
+
+ aclr_bold,aclr_red,
+ epath,
+ aclr_reset) < 0)
+ return -1;
+
if (fprintf(
stderr,
"%s%s%s:%s %s%s%s %s%s%s()%s, %s%sline %d%s%s%s%s%s.\n",