summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/perk/perk.h15
-rw-r--r--src/internal/perk_errinfo_impl.c25
-rw-r--r--src/internal/perk_errinfo_impl.h16
-rw-r--r--src/output/pe_output_error.c28
4 files changed, 44 insertions, 40 deletions
diff --git a/include/perk/perk.h b/include/perk/perk.h
index 99bdb8f..8624838 100644
--- a/include/perk/perk.h
+++ b/include/perk/perk.h
@@ -139,12 +139,15 @@ struct pe_io_ctx {
};
struct pe_error_info {
- int syserror;
- int liberror;
- const char * function;
- int line;
- unsigned flags;
- void * ctx;
+ const struct pe_driver_ctx * edctx;
+ const struct pe_unit_ctx * euctx;
+ const char * eunit;
+ int esyscode;
+ int elibcode;
+ const char * efunction;
+ int eline;
+ unsigned eflags;
+ void * eany;
};
struct pe_common_ctx {
diff --git a/src/internal/perk_errinfo_impl.c b/src/internal/perk_errinfo_impl.c
index df01b3b..bd082d4 100644
--- a/src/internal/perk_errinfo_impl.c
+++ b/src/internal/perk_errinfo_impl.c
@@ -10,12 +10,12 @@
int pe_record_error(
const struct pe_driver_ctx * dctx,
- int syserror,
- int liberror,
- const char * function,
- int line,
- unsigned flags,
- void * ctx)
+ int esyscode,
+ int elibcode,
+ const char * efunction,
+ int eline,
+ unsigned eflags,
+ void * eany)
{
struct pe_driver_ctx_impl * ictx;
struct pe_error_info * erri;
@@ -28,12 +28,13 @@ int pe_record_error(
*ictx->errinfp = &ictx->erribuf[ictx->errinfp - ictx->erriptr];
erri = *ictx->errinfp;
- erri->syserror = syserror;
- erri->liberror = liberror;
- erri->function = function;
- erri->line = line;
- erri->flags = flags;
- erri->ctx = ctx;
+ erri->edctx = dctx;
+ erri->esyscode = esyscode;
+ erri->elibcode = elibcode;
+ erri->efunction = efunction;
+ erri->eline = eline;
+ erri->eflags = eflags;
+ erri->eany = eany;
ictx->errinfp++;
diff --git a/src/internal/perk_errinfo_impl.h b/src/internal/perk_errinfo_impl.h
index f9bd80c..9fac492 100644
--- a/src/internal/perk_errinfo_impl.h
+++ b/src/internal/perk_errinfo_impl.h
@@ -9,12 +9,12 @@
int pe_record_error(
const struct pe_driver_ctx *,
- int syserror,
- int liberror,
- const char * function,
- int line,
- unsigned flags,
- void * ctx);
+ int esyscode,
+ int elibcode,
+ const char * efunction,
+ int eline,
+ unsigned eflags,
+ void * ectx);
#define PERK_SYSTEM_ERROR(dctx) \
pe_record_error( \
@@ -58,11 +58,11 @@ int pe_record_error(
PERK_ERROR_TOP_LEVEL, \
0)
-#define PERK_CUSTOM_ERROR(dctx,liberror) \
+#define PERK_CUSTOM_ERROR(dctx,elibcode) \
pe_record_error( \
dctx, \
0, \
- liberror, \
+ elibcode, \
__func__, \
__LINE__, \
PERK_ERROR_TOP_LEVEL \
diff --git a/src/output/pe_output_error.c b/src/output/pe_output_error.c
index 33e2b7a..c08a7d5 100644
--- a/src/output/pe_output_error.c
+++ b/src/output/pe_output_error.c
@@ -33,13 +33,13 @@ static const char const * const pe_error_strings[PERK_ERR_CAP] = {
static const char * pe_output_error_header(const struct pe_error_info * erri)
{
- if (erri->flags & PERK_ERROR_CHILD)
+ if (erri->eflags & PERK_ERROR_CHILD)
return "exec error upon";
- else if (erri->flags & PERK_ERROR_TOP_LEVEL)
+ else if (erri->eflags & PERK_ERROR_TOP_LEVEL)
return "error logged in";
- else if (erri->flags & PERK_ERROR_NESTED)
+ else if (erri->eflags & PERK_ERROR_NESTED)
return "< returned to >";
else
@@ -48,22 +48,22 @@ static const char * pe_output_error_header(const struct pe_error_info * erri)
static const char * pe_output_strerror(const struct pe_error_info * erri)
{
- if (erri->flags & PERK_ERROR_CUSTOM)
- return ((erri->liberror < 0) || (erri->liberror >= PERK_ERR_CAP))
+ if (erri->eflags & PERK_ERROR_CUSTOM)
+ return ((erri->elibcode < 0) || (erri->elibcode >= PERK_ERR_CAP))
? "internal error: please report to the maintainer"
- : pe_error_strings[erri->liberror];
+ : pe_error_strings[erri->elibcode];
- else if (erri->flags & PERK_ERROR_NESTED)
+ else if (erri->eflags & PERK_ERROR_NESTED)
return "";
- else if (erri->flags & PERK_ERROR_CHILD)
+ else if (erri->eflags & PERK_ERROR_CHILD)
return "(see child process error messages)";
- else if (erri->syserror == ENOBUFS)
+ else if (erri->esyscode == ENOBUFS)
return "input error: string length exceeds buffer size.";
else
- return strerror(erri->syserror);
+ return strerror(erri->esyscode);
}
static int pe_output_error_record_plain(
@@ -75,8 +75,8 @@ static int pe_output_error_record_plain(
if (fprintf(stderr,"%s: %s %s(), line %d%s%s.\n",
dctx->program,
pe_output_error_header(erri),
- erri->function,
- erri->line,
+ erri->efunction,
+ erri->eline,
strlen(errdesc) ? ": " : "",
errdesc) < 0)
return -1;
@@ -103,11 +103,11 @@ static int pe_output_error_record_annotated(
aclr_reset,
aclr_bold,aclr_blue,
- erri->function,
+ erri->efunction,
aclr_reset,
aclr_bold,aclr_green,
- erri->line,
+ erri->eline,
aclr_reset,
strlen(errdesc) ? ": " : "",