From db9be296cb539c271f30c29ef313a61e9da0f32d Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Fri, 4 Dec 2015 10:11:33 -0500 Subject: [PATCH] core/file: Add better error reporting Printing out the filename of the file that broke is generally helpful. Signed-off-by: Anna Schumaker --- core/file.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/file.c b/core/file.c index 3b122868..38464fbb 100644 --- a/core/file.c +++ b/core/file.c @@ -13,8 +13,8 @@ const gchar *OCARINA_DIR = "ocarina-debug"; const gchar *OCARINA_DIR = "ocarina"; #endif -#define REPORT_ERROR() \ - printf("%s (%s:%d): %s\n", __func__, __FILE__, __LINE__, strerror(errno)) +#define REPORT_ERROR(fname) \ + printf("%s (%s:%d): %s: %s\n", __func__, __FILE__, __LINE__, fname, strerror(errno)) static gchar *__file_path(gchar *name) @@ -29,7 +29,7 @@ static bool __file_mkdir() g_free(dir); if (ret != 0) - REPORT_ERROR(); + REPORT_ERROR(dir); return ret == 0; } @@ -73,7 +73,7 @@ static bool __file_open_common(struct file *file, enum open_mode mode) g_free(path); if (!file->f_file) { - REPORT_ERROR(); + REPORT_ERROR(file->f_name); return false; } @@ -149,6 +149,6 @@ int file_writef(struct file *file, const char *fmt, ...) va_end(argp); if (ret < 0) - REPORT_ERROR(); + REPORT_ERROR(file->f_name); return ret; }