Commit f20bd74c authored by Tristan Cavelier's avatar Tristan Cavelier

createErrorObject Modified

parent 7ea4a355
...@@ -17,37 +17,19 @@ var storage = function(spec, my) { ...@@ -17,37 +17,19 @@ var storage = function(spec, my) {
/** /**
* Creates the error object for all errors * Creates the error object for all errors
* @method createErrorObject * @method createErrorObject
* @param {string} error_code The error code * @param {number} error_code The error code
* @param {string} error_name The error name
* @param {string} message The error message * @param {string} message The error message
* @param {object} error_object The error object (optional)
* @return {object} Error object * @return {object} Error object
*/ */
that.createErrorObject = function (error_code, message) { that.createErrorObject = function (error_code, error_name,
var error_object, assignErrorValues; message, error_object) {
error_object = error_object || {};
error_object = { error_okject["status"] = error_code || 0;
"status":error_code, error_object["statusText"] = error_name;
"message":message, error_object["error"] = error_name.toLowerCase().split(' ').join('_');
"reason":message error_object["message"] = error_object["error"] = message;
};
assignErrorValues = function (statusText) {
var tmp = '';
error_object.statusText = statusText;
error_object.error = statusText.toLowerCase().split(' ').join('_');
};
switch(code) {
case 409:
assignErrorValues('Conflict');
break;
case 403:
assignErrorValues('Forbidden');
break;
case 404:
assignErrorValues('Not found');
break;
}
return error_object; return error_object;
}; };
......
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