summaryrefslogtreecommitdiff
path: root/girepository/girmodule.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-02-11 17:18:28 -0500
committerColin Walters <walters@verbum.org>2010-02-11 17:18:28 -0500
commita9e6ae83ffa54194adc01e84c85ac336c59fd520 (patch)
tree959debe8779fd17e0177ef33bc157f91159fbbe3 /girepository/girmodule.c
parentaaef4935d212ede7df24e67cd3afac19a322e775 (diff)
downloadgobject-introspection-a9e6ae83ffa54194adc01e84c85ac336c59fd520.tar.gz
[g-ir-compiler] Slightly less lame error messages
To make things really better we should track the line origin of element from the .gir file (and actually we need to do better checking in the scanner), but this is slightly less lame.
Diffstat (limited to 'girepository/girmodule.c')
-rw-r--r--girepository/girmodule.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/girepository/girmodule.c b/girepository/girmodule.c
index bf1e856b..b954d15d 100644
--- a/girepository/girmodule.c
+++ b/girepository/girmodule.c
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include "girmodule.h"
#include "girnode.h"
@@ -75,6 +76,39 @@ g_ir_module_free (GIrModule *module)
g_free (module);
}
+/**
+ * g_ir_module_fatal:
+ * @module: Current module
+ * @line: Origin line number, or 0 if unknown
+ * @msg: printf-format string
+ * @args: Remaining arguments
+ *
+ * Report a fatal error, then exit.
+ */
+void
+g_ir_module_fatal (GIrModule *module,
+ guint line,
+ const char *msg,
+ ...)
+{
+ char *formatted;
+
+ va_list args;
+
+ va_start (args, msg);
+
+ formatted = g_strdup_vprintf (msg, args);
+
+ if (line)
+ g_printerr ("%s-%s.gir:%d: error: %s\n", module->name, module->version, line, formatted);
+ else
+ g_printerr ("%s-%s.gir: error: %s\n", module->name, module->version, formatted);
+
+ exit (1);
+
+ va_end (args);
+}
+
static void
add_alias_foreach (gpointer key,
gpointer value,