diff --git a/girepository/girparser.c b/girepository/girparser.c
index 0a4a65d..144ca5d 100644
--- a/girepository/girparser.c
+++ b/girepository/girparser.c
@@ -3553,10 +3553,25 @@ _g_ir_parser_parse_file (GIrParser   *parser,
     *dash = '\0';
 
   if (!g_file_get_contents (filename, &buffer, &length, error))
-    return NULL;
+    {
+      g_set_error (error,
+                   G_MARKUP_ERROR,
+                   G_MARKUP_ERROR_INVALID_CONTENT,
+                   "Could not retreive contents from file");
+      return NULL;
+    }
+
 
   module = _g_ir_parser_parse_string (parser, namespace, filename, buffer, length, error);
 
+  if (module == NULL)
+    {
+      g_set_error (error,
+                   G_MARKUP_ERROR,
+                   G_MARKUP_ERROR_INVALID_CONTENT,
+                   "Expected a namespace tag in the gir file");
+    }
+
   g_free (namespace);
 
   g_free (buffer);
