From 8046e11445ba71b767d4fde08ce1e43e0dcd0359 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 2 Jun 2013 13:47:19 +0200 Subject: use GLib's GError information to yield errors * results in better error messages, e.g. when opening files * the case that a file to be opened (EB) exists but is not readably is handled for the first time --- src/parser.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index 4dbec88..aed9348 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -177,10 +177,11 @@ Execute::macro(const gchar *macro, bool locals) void Execute::file(const gchar *filename, bool locals) { + GError *gerror = NULL; gchar *macro_str, *p; - if (!g_file_get_contents(filename, ¯o_str, NULL, NULL)) - throw State::Error("Error reading file \"%s\"", filename); + if (!g_file_get_contents(filename, ¯o_str, NULL, &gerror)) + throw State::GError(gerror); /* only when executing files, ignore Hash-Bang line */ if (*macro_str == '#') p = MAX(strchr(macro_str, '\r'), strchr(macro_str, '\n'))+1; -- cgit v1.2.3