[Groonga-commit] droonga/express-droonga at c444f64 [master] Use constant for HTTP status codes

Back to archive index

YUKI Hiroshi null+****@clear*****
Mon Apr 20 14:55:40 JST 2015


YUKI Hiroshi	2015-04-20 14:55:40 +0900 (Mon, 20 Apr 2015)

  New Revision: c444f642fd705fb724fee9987d2b83dfe7002139
  https://github.com/droonga/express-droonga/commit/c444f642fd705fb724fee9987d2b83dfe7002139

  Message:
    Use constant for HTTP status codes

  Modified files:
    lib/adapter/http.js

  Modified: lib/adapter/http.js (+6 -4)
===================================================================
--- lib/adapter/http.js    2015-04-20 12:27:28 +0900 (97c9749)
+++ lib/adapter/http.js    2015-04-20 14:55:40 +0900 (527d7dc)
@@ -5,6 +5,8 @@ var ConsoleLogger = require('../console-logger').ConsoleLogger;
 
 var CONNECTION_RETRY_INTERVAL = 1000;
 
+var ERROR_INTERNAL = 500;
+
 function createRequestResponseHandler(params) {
   params = params || {};
   var connectionPool = params.connectionPool;
@@ -46,7 +48,7 @@ function createRequestResponseHandler(params) {
         };
         if (error.detail)
           errorBody.detail = error.detail;
-        response.status(error.code || 500).jsonp(errorBody);
+        response.status(error.code || ERROR_INTERNAL).jsonp(errorBody);
         return;
       }
       var connection = connectionPool.get();
@@ -64,7 +66,7 @@ function createRequestResponseHandler(params) {
           definition.onRequest(request, wrappedConnection, response);
         } catch(error) {
           wrappedConnection.destroy();
-          response.status(500).jsonp({ error: error.message });
+          response.status(ERROR_INTERNAL).jsonp({ error: error.message });
         }
       } else {
         wrappedConnection.emit(commandName, request.query);
@@ -102,7 +104,7 @@ function createGenericHandler(params) {
         };
         if (error.detail)
           errorBody.detail = error.detail;
-        response.status(error.code || 500).jsonp(errorBody);
+        response.status(error.code || ERROR_INTERNAL).jsonp(errorBody);
         return;
       }
       var connection = connectionPool.get();
@@ -120,7 +122,7 @@ function createGenericHandler(params) {
         definition.onHandle(request, response, wrappedConnection);
       } catch(error) {
         wrappedConnection.destroy();
-        response.status(500).jsonp({ error: error.message });
+        response.status(ERROR_INTERNAL).jsonp({ error: error.message });
       }
     };
     if (typeof definition.authorize == 'function')
-------------- next part --------------
HTML����������������������������...
Download 



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