[Groonga-commit] groonga/gcs [master] Handle errors returned from select

Back to archive index

null+****@clear***** null+****@clear*****
2012年 6月 22日 (金) 18:20:20 JST


Yoji SHIDARA	2012-06-22 18:20:20 +0900 (Fri, 22 Jun 2012)

  New Revision: ee8114b90e9ee5fce9c70a6f36ad8a41be4893a9
  https://github.com/groonga/gcs/commit/ee8114b90e9ee5fce9c70a6f36ad8a41be4893a9

  Log:
    Handle errors returned from select

  Modified files:
    lib/api/2011-02-01/search.js

  Modified: lib/api/2011-02-01/search.js (+19 -5)
===================================================================
--- lib/api/2011-02-01/search.js    2012-06-22 18:19:19 +0900 (019b4f2)
+++ lib/api/2011-02-01/search.js    2012-06-22 18:20:20 +0900 (dcbc2eb)
@@ -45,16 +45,30 @@ exports.createHandler = function(database) {
     };
 
     select(database, options, function(error, data) {
-      if (error) {
-        throw error;
-      }
       var finishedAt = new Date();
       var elapsedTime = finishedAt - startedAt;
+      var rid = '000000000000000000000000000000000000000000000000000000000000000';
       var info = {
-        rid: '000000000000000000000000000000000000000000000000000000000000000',
+        rid: rid,
         'time-ms': elapsedTime,
-        'cpu-time-ms': 0
+        'cpu-time-ms': 0 // TODO
       };
+      if (error) {
+        var body = {
+          error: 'info',
+          rid: rid,
+          'time-ms': elapsedTime,
+          'cpu-time-ms': 0, // TODO
+          messages: [
+            {
+              severity: "fatal",
+              code: "",
+              message: error.message
+            }
+          ]
+        };
+        return response.send(body, 400); // TODO
+      }
       var result = {
         rank: '-text_relevance', // FIXME
         'match-expr': '', // FIXME
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
Download 



Groonga-commit メーリングリストの案内
Back to archive index