[Groonga-commit] groonga/groonga-admin at b6010ba [master] Add method to handle both success and error responses

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Sep 26 11:54:59 JST 2016


YUKI Hiroshi	2016-09-26 11:54:59 +0900 (Mon, 26 Sep 2016)

  New Revision: b6010bacab3290562efb85d31d5911a0fecc8e6b
  https://github.com/groonga/groonga-admin/commit/b6010bacab3290562efb85d31d5911a0fecc8e6b

  Merged 9791dae: Merge pull request #14 from groonga/features/set-thread-limit-to-1

  Message:
    Add method to handle both success and error responses

  Modified files:
    app/scripts/groonga-client.js

  Modified: app/scripts/groonga-client.js (+16 -0)
===================================================================
--- app/scripts/groonga-client.js    2016-09-26 11:54:43 +0900 (80c3147)
+++ app/scripts/groonga-client.js    2016-09-26 11:54:59 +0900 (5976cc4)
@@ -30,6 +30,22 @@
     this._parameters = parameters;
   };
 
+  GroongaClient.Request.prototype.then = function(successCallback, errorCallback) {
+    var name = this._name;
+    return this._rawRequest.then(
+      function(rawResponse) {
+        var ResponseConstructor = GroongaClient.Response.find(name);
+        var response = new ResponseConstructor(rawResponse.data);
+        return successCallback(response, rawResponse);
+      },
+      function(rawResponse) {
+        var ResponseConstructor = GroongaClient.Response.find(name);
+        var response = new ResponseConstructor(rawResponse.data);
+        return errorCallback(response, rawResponse);
+      }
+    );
+  };
+
   GroongaClient.Request.prototype.success = function(callback) {
     var name = this._name;
     return this._rawRequest.then(function(rawResponse) {
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index