aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/error.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-09-09 01:13:23 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-09-09 01:13:23 +0200
commite1db398049adf8ea37cebfc8f816be12f9ba131c (patch)
treeae6efacc5172caf211abe65510c105029ee2e09e /src/common/error.c
parentd97662894bab06133830c2936986b7f1e57ae26f (diff)
downloadblogc-e1db398049adf8ea37cebfc8f816be12f9ba131c.tar.gz
blogc-e1db398049adf8ea37cebfc8f816be12f9ba131c.tar.bz2
blogc-e1db398049adf8ea37cebfc8f816be12f9ba131c.zip
*: centralize error handling
Diffstat (limited to 'src/common/error.c')
-rw-r--r--src/common/error.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/common/error.c b/src/common/error.c
index dbc1d81..78cdc86 100644
--- a/src/common/error.c
+++ b/src/common/error.c
@@ -101,6 +101,35 @@ bc_error_parser(int 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)
+{
+ if (err == NULL)
+ return;
+
+ switch(err->type) {
+ case BLOGC_ERROR_SOURCE_PARSER:
+ fprintf(stderr, "blogc: error: source: %s\n", err->msg);
+ break;
+ case BLOGC_ERROR_TEMPLATE_PARSER:
+ fprintf(stderr, "blogc: error: template: %s\n", err->msg);
+ break;
+ case BLOGC_ERROR_LOADER:
+ fprintf(stderr, "blogc: error: loader: %s\n", err->msg);
+ break;
+ case BLOGC_ERROR_FILE:
+ fprintf(stderr, "blogc: error: file: %s\n", err->msg);
+ break;
+ case BLOGC_WARNING_DATETIME_PARSER:
+ fprintf(stderr, "blogc: warning: datetime: %s\n", err->msg);
+ break;
+ default:
+ fprintf(stderr, "blogc: error: %s\n", err->msg);
+ }
+}
+
+
void
bc_error_free(bc_error_t *err)
{