YUKI Hiroshi
null+****@clear*****
Wed Nov 21 15:47:43 JST 2012
YUKI Hiroshi 2012-11-21 15:47:43 +0900 (Wed, 21 Nov 2012) New Revision: ef6b2adf2cc565ceaea7abd132ee82c156ee05d5 https://github.com/groonga/gcs/commit/ef6b2adf2cc565ceaea7abd132ee82c156ee05d5 Log: Fix status code of "resource not found" error Modified files: lib/api/2011-02-01/configuration.js lib/errors.js Modified: lib/api/2011-02-01/configuration.js (+12 -4) =================================================================== --- lib/api/2011-02-01/configuration.js 2012-11-21 15:38:21 +0900 (56119e4) +++ lib/api/2011-02-01/configuration.js 2012-11-21 15:47:43 +0900 (3b0603c) @@ -311,7 +311,7 @@ function assertValidFieldOptions(request, type, domainName) { if (options.some(function(name) { return validOptions.indexOf(name) < 0; })) - throw new errors.NotFoundError('Domain not found: ' + domainName); + throw new errors.ResourceNotFoundError('Domain not found: ' + domainName); } function getFieldOption(option, request, type) { @@ -329,7 +329,7 @@ handlers.DefineIndexField = function(context, request, response, config) { return new Domain(domainName, context); }); if (!domain || !domain.exists()) - throw new errors.NotFoundError('Domain not found: ' + domainName); + throw new errors.ResourceNotFoundError('Domain not found: ' + domainName); var fieldName = request.query['IndexField.IndexFieldName'] || ''; var fieldType = request.query['IndexField.IndexFieldType'] || ''; @@ -371,7 +371,7 @@ handlers.DeleteIndexField = function(context, request, response, config) { return new Domain(request.query.DomainName || '', context); }); if (!domain || !domain.exists()) - throw new errors.NotFoundError('Domain not found: ' + domainName); + throw new errors.ResourceNotFoundError('Domain not found: ' + domainName); var fieldName = request.query['IndexFieldName'] || ''; var field = handleIndexFieldValidationError(function() { @@ -605,7 +605,15 @@ exports.createHandler = function(context, config) { var body, code; if (error.isSenderError) { body = createSenderErrorResponse(error.code, error, request.id); - code = error.type == 'FieldOptionConflictError' ? 409 : 400; + switch (error.type) { + case 'FieldOptionConflictError': + case 'ResourceNotFoundError': + code = 409; + break; + default: + code = 400; + break; + } } else { body= createCommonErrorResponse('InternalFailure', error.stack || error, request.id); code = 500; Modified: lib/errors.js (+3 -3) =================================================================== --- lib/errors.js 2012-11-21 15:38:21 +0900 (dd6c1fc) +++ lib/errors.js 2012-11-21 15:47:43 +0900 (83cf128) @@ -20,12 +20,12 @@ function FieldOptionConflictError(message) { exports.FieldOptionConflictError = FieldOptionConflictError; -function NotFoundError(message) { +function ResourceNotFoundError(message) { var error = new Error(message); error.isNotFoundError = true; error.isSenderError = true; error.code = 'ResourceNotFound'; - error.type = 'NotFoundError'; + error.type = 'ResourceNotFoundError'; return error; } -exports.NotFoundError = NotFoundError; +exports.ResourceNotFoundError = ResourceNotFoundError; -------------- next part -------------- HTML����������������������������... 下载