Navigation Menu

Skip to content

Commit

Permalink
Use constant for HTTP status codes
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 20, 2015
1 parent 7f29afd commit c444f64
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/adapter/http.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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')
Expand Down

0 comments on commit c444f64

Please sign in to comment.