core/file: Add better error reporting

Printing out the filename of the file that broke is generally helpful.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-12-04 10:11:33 -05:00
parent 5b5b7ebea6
commit db9be296cb
1 changed files with 5 additions and 5 deletions

View File

@ -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;
}