From 0c7753ef37f875b288fc8c5d1c6a64fa61f4d149 Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Fri, 16 Sep 2016 20:56:51 +0200 Subject: error: added prefix support to bc_error_print --- src/common/error.c | 5 ++++- src/common/error.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/error.c b/src/common/error.c index a6a5f24..b507e90 100644 --- a/src/common/error.c +++ b/src/common/error.c @@ -103,11 +103,14 @@ bc_error_parser(bc_error_type_t type, const char *src, size_t src_len, // error handling is centralized here for the sake of simplicity :/ void -bc_error_print(bc_error_t *err) +bc_error_print(bc_error_t *err, const char *prefix) { if (err == NULL) return; + if (prefix != NULL) + fprintf(stderr, "%s: ", prefix); + switch(err->type) { case BC_ERROR_CONFIG_PARSER: fprintf(stderr, "error: config-parser: %s\n", err->msg); diff --git a/src/common/error.h b/src/common/error.h index d65a3e7..5ac2b15 100644 --- a/src/common/error.h +++ b/src/common/error.h @@ -34,7 +34,7 @@ bc_error_t* bc_error_new(bc_error_type_t type, const char *msg); bc_error_t* bc_error_new_printf(bc_error_type_t type, const char *format, ...); bc_error_t* bc_error_parser(bc_error_type_t type, const char *src, size_t src_len, size_t current, const char *format, ...); -void bc_error_print(bc_error_t *err); +void bc_error_print(bc_error_t *err, const char *prefix); void bc_error_free(bc_error_t *err); #endif /* _ERROR_H */ -- cgit v1.2.3-18-g5258