YUKI Hiroshi
null+****@clear*****
Mon Jun 15 18:44:45 JST 2015
YUKI Hiroshi 2015-06-15 18:44:45 +0900 (Mon, 15 Jun 2015) New Revision: 03835efe848d04d00805fe531d000a991ffab229 https://github.com/droonga/express-droonga/commit/03835efe848d04d00805fe531d000a991ffab229 Message: Throw errors with expected format Modified files: lib/adapter/api/groonga/loader.js Modified: lib/adapter/api/groonga/loader.js (+10 -2) =================================================================== --- lib/adapter/api/groonga/loader.js 2015-06-15 18:44:18 +0900 (c51744b) +++ lib/adapter/api/groonga/loader.js 2015-06-15 18:44:45 +0900 (6c740ef) @@ -108,7 +108,11 @@ Loader.prototype._onValue = function _onValue(value) { } else if (value) { if (typeof value != 'object') - throw new Error('invalid record: ' + JSON.stringify(value)); + throw { + statusCode: statusCodes.INVALID_ARGUMENT, + message: 'invalid record: <' + JSON.stringify(value) + '>', + httpStatusCode: httpStatusCodes.BAD_REQUEST + }; Object.keys(value).forEach(function(key) { if (key == '_key') { message.key = value[key]; @@ -118,7 +122,11 @@ Loader.prototype._onValue = function _onValue(value) { }); } else { - throw new Error('invalid record: ' + value); + throw { + statusCode: statusCodes.INVALID_ARGUMENT, + message: 'invalid record: <' + JSON.stringify(value) + '>', + httpStatusCode: httpStatusCodes.BAD_REQUEST + }; } this._connection.emit('add', message, function(error, message) { -------------- next part -------------- HTML����������������������������...Download