[Groonga-commit] groonga/groonga at 596fd8c [master] Add more information to error message

Zurück zum Archiv-Index

Kouhei Sutou null+****@clear*****
Tue Dec 22 21:17:35 JST 2015


Kouhei Sutou	2015-12-22 21:17:35 +0900 (Tue, 22 Dec 2015)

  New Revision: 596fd8c5009509dbeb2ce423670b5b2af4a2db1e
  https://github.com/groonga/groonga/commit/596fd8c5009509dbeb2ce423670b5b2af4a2db1e

  Message:
    Add more information to error message

  Modified files:
    lib/hash.c
    lib/ii.c
    lib/pat.c
    lib/store.c

  Modified: lib/hash.c (+8 -4)
===================================================================
--- lib/hash.c    2015-12-17 19:40:45 +0900 (1105a20)
+++ lib/hash.c    2015-12-22 21:17:35 +0900 (368dd3c)
@@ -580,7 +580,8 @@ grn_array_open(grn_ctx *ctx, const char *path)
     grn_io * const io = grn_io_open(ctx, path, grn_io_auto);
     if (io) {
       struct grn_array_header * const header = grn_io_header(io);
-      if (grn_io_get_type(io) == GRN_TABLE_NO_KEY) {
+      uint32_t io_type = grn_io_get_type(io);
+      if (io_type == GRN_TABLE_NO_KEY) {
         grn_array * const array = (grn_array *)GRN_MALLOC(sizeof(grn_array));
         if (array) {
           if (!(header->flags & GRN_ARRAY_TINY)) {
@@ -602,7 +603,8 @@ grn_array_open(grn_ctx *ctx, const char *path)
           GRN_FREE(array);
         }
       } else {
-        ERR(GRN_INVALID_FORMAT, "file type unmatch");
+        ERR(GRN_INVALID_FORMAT, "[table][array] file type must be %#x: <%#x>",
+            GRN_TABLE_NO_KEY, io_type);
       }
       grn_io_close(ctx, io);
     }
@@ -1824,7 +1826,8 @@ grn_hash_open(grn_ctx *ctx, const char *path)
     grn_io * const io = grn_io_open(ctx, path, grn_io_auto);
     if (io) {
       grn_hash_header_common * const header = grn_io_header(io);
-      if (grn_io_get_type(io) == GRN_TABLE_HASH_KEY) {
+      uint32_t io_type = grn_io_get_type(io);
+      if (io_type == GRN_TABLE_HASH_KEY) {
         grn_hash * const hash = (grn_hash *)GRN_MALLOC(sizeof(grn_hash));
         if (hash) {
           if (!(header->flags & GRN_HASH_TINY)) {
@@ -1858,7 +1861,8 @@ grn_hash_open(grn_ctx *ctx, const char *path)
           GRN_FREE(hash);
         }
       } else {
-        ERR(GRN_INVALID_FORMAT, "file type unmatch");
+        ERR(GRN_INVALID_FORMAT, "[table][hash] file type must be %#x: <%#x>",
+            GRN_TABLE_HASH_KEY, io_type);
       }
       grn_io_close(ctx, io);
     }

  Modified: lib/ii.c (+5 -2)
===================================================================
--- lib/ii.c    2015-12-17 19:40:45 +0900 (e7eb9af)
+++ lib/ii.c    2015-12-22 21:17:35 +0900 (2572a16)
@@ -3720,6 +3720,7 @@ grn_ii_open(grn_ctx *ctx, const char *path, grn_obj *lexicon)
   grn_ii *ii;
   char path2[PATH_MAX];
   struct grn_ii_header *header;
+  uint32_t io_type;
   grn_obj_flags lflags;
   grn_encoding encoding;
   grn_obj *tokenizer;
@@ -3738,8 +3739,10 @@ grn_ii_open(grn_ctx *ctx, const char *path, grn_obj *lexicon)
     return NULL;
   }
   header = grn_io_header(seg);
-  if (grn_io_get_type(seg) != GRN_COLUMN_INDEX) {
-    ERR(GRN_INVALID_FORMAT, "file type unmatch");
+  io_type = grn_io_get_type(seg);
+  if (io_type != GRN_COLUMN_INDEX) {
+    ERR(GRN_INVALID_FORMAT, "[column][index] file type must be %#x: <%#x>",
+        GRN_COLUMN_INDEX, io_type);
     grn_io_close(ctx, seg);
     grn_io_close(ctx, chunk);
     return NULL;

  Modified: lib/pat.c (+5 -2)
===================================================================
--- lib/pat.c    2015-12-17 19:40:45 +0900 (595c4fe)
+++ lib/pat.c    2015-12-22 21:17:35 +0900 (d24d49c)
@@ -586,11 +586,14 @@ grn_pat_open(grn_ctx *ctx, const char *path)
   grn_pat *pat;
   pat_node *node0;
   struct grn_pat_header *header;
+  uint32_t io_type;
   io = grn_io_open(ctx, path, grn_io_auto);
   if (!io) { return NULL; }
   header = grn_io_header(io);
-  if (grn_io_get_type(io) != GRN_TABLE_PAT_KEY) {
-    ERR(GRN_INVALID_FORMAT, "file type unmatch");
+  io_type = grn_io_get_type(io);
+  if (io_type != GRN_TABLE_PAT_KEY) {
+    ERR(GRN_INVALID_FORMAT, "[table][pat] file type must be %#x: <%#x>",
+        GRN_TABLE_PAT_KEY, io_type);
     grn_io_close(ctx, io);
     return NULL;
   }

  Modified: lib/store.c (+10 -4)
===================================================================
--- lib/store.c    2015-12-17 19:40:45 +0900 (f23d662)
+++ lib/store.c    2015-12-22 21:17:35 +0900 (4d0aeb2)
@@ -77,11 +77,14 @@ grn_ra_open(grn_ctx *ctx, const char *path)
   int n_elm, w_elm;
   grn_ra *ra = NULL;
   struct grn_ra_header *header;
+  uint32_t io_type;
   io = grn_io_open(ctx, path, grn_io_auto);
   if (!io) { return NULL; }
   header = grn_io_header(io);
-  if (grn_io_get_type(io) != GRN_COLUMN_FIX_SIZE) {
-    ERR(GRN_INVALID_FORMAT, "file type unmatch");
+  io_type = grn_io_get_type(io);
+  if (io_type != GRN_COLUMN_FIX_SIZE) {
+    ERR(GRN_INVALID_FORMAT, "[column][fix-size] file type must be %#x: <%#x>",
+        GRN_COLUMN_FIX_SIZE, io_type);
     grn_io_close(ctx, io);
     return NULL;
   }
@@ -408,11 +411,14 @@ grn_ja_open(grn_ctx *ctx, const char *path)
   grn_ja *ja = NULL;
   struct grn_ja_header *header;
   struct grn_ja_header_v2 *header_v2;
+  uint32_t io_type;
   io = grn_io_open(ctx, path, grn_io_auto);
   if (!io) { return NULL; }
   header_v2 = grn_io_header(io);
-  if (grn_io_get_type(io) != GRN_COLUMN_VAR_SIZE) {
-    ERR(GRN_INVALID_FORMAT, "file type unmatch");
+  io_type = grn_io_get_type(io);
+  if (io_type != GRN_COLUMN_VAR_SIZE) {
+    ERR(GRN_INVALID_FORMAT, "[column][var-size] file type must be %#x: <%#x>",
+        GRN_COLUMN_VAR_SIZE, io_type);
     grn_io_close(ctx, io);
     return NULL;
   }
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index