aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/blogc/main.c4
-rw-r--r--src/blogc/renderer.c2
-rw-r--r--src/common/error.c5
-rw-r--r--src/common/error.h2
4 files changed, 8 insertions, 5 deletions
diff --git a/src/blogc/main.c b/src/blogc/main.c
index 992b9e7..35d9f69 100644
--- a/src/blogc/main.c
+++ b/src/blogc/main.c
@@ -223,7 +223,7 @@ main(int argc, char **argv)
bc_slist_t *s = blogc_source_parse_from_files(config, sources, &err);
if (err != NULL) {
- bc_error_print(err);
+ bc_error_print(err, "blogc");
rv = 2;
goto cleanup2;
}
@@ -250,7 +250,7 @@ main(int argc, char **argv)
bc_slist_t* l = blogc_template_parse_from_file(template, &err);
if (err != NULL) {
- bc_error_print(err);
+ bc_error_print(err, "blogc");
rv = 2;
goto cleanup3;
}
diff --git a/src/blogc/renderer.c b/src/blogc/renderer.c
index e0f1da6..b4d7a90 100644
--- a/src/blogc/renderer.c
+++ b/src/blogc/renderer.c
@@ -46,7 +46,7 @@ blogc_format_date(const char *date, bc_trie_t *global, bc_trie_t *local)
bc_error_t *err = NULL;
char *rv = blogc_convert_datetime(date, date_format, &err);
if (err != NULL) {
- bc_error_print(err);
+ bc_error_print(err, "blogc");
bc_error_free(err);
return bc_strdup(date);
}
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 */