Commit fbe16407 authored by Tristan Cavelier's avatar Tristan Cavelier

throwError replaced by createErrorObject

parent 90d37ed6
...@@ -76,44 +76,40 @@ var utilities = { ...@@ -76,44 +76,40 @@ var utilities = {
}, },
/** /**
* @method throwError - Creates the error object for all errors * Creates the error object for all errors
* @param {code} string - the error code. * @method createErrorObject
* @param {reason} string - the error reason * @param {string} error_code The error code
* @returns {e} object - error object * @param {string} message The error message
* @return {object} Error object
*/ */
throwError : function (code, reason) { createErrorObject: function (error_code, message) {
var statusText, error, message, errorObject; var error_object, assignErrorValues;
switch(code) { error_object = {
"status":error_code,
"message":message,
"reason":message
};
case 409: assignErrorValues = function (statusText) {
statusText = 'Conflict'; var tmp = '';
error = 'conflict'; error_object.statusText = statusText;
message = 'Document update conflict.'; error_object.error = statusText.toLowerCase().split(' ').join('_');
break; };
case 403: switch(code) {
statusText = 'Forbidden'; case 409:
error = 'forbidden'; assignErrorValues('Conflict');
message = 'Forbidden'; break;
break; case 403:
assignErrorValues('Forbidden');
case 404: break;
statusText = 'Not found'; case 404:
error = 'not found'; assignErrorValues('Not found');
message = 'Document not found.'; break;
break;
} }
// create object return error_object;
errorObject = ({
status:code,
statusText:statusText,
error:error,
message:message,
reason:reason
});
return errorObject;
}, },
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment