replaced all stop callbacks with customError callbacks. Fixes #270

This commit is contained in:
Peter 'Pita' Martischka 2011-12-10 16:46:47 +01:00
parent 22fd5ae33d
commit 6684d6ed52
7 changed files with 59 additions and 38 deletions

View file

@ -19,6 +19,7 @@
*/
var ERR = require("async-stacktrace");
var customError = require("../utils/customError");
require("../db/Pad");
var db = require("./DB").db;
@ -47,7 +48,7 @@ exports.getPad = function(id, text, callback)
//check if this is a valid padId
if(!exports.isValidPadId(id))
{
callback({stop: id + " is not a valid padId"});
callback(new customError(id + " is not a valid padId","apierror"));
return;
}
@ -64,14 +65,14 @@ exports.getPad = function(id, text, callback)
//check if text is a string
if(typeof text != "string")
{
callback({stop: "text is not a string"});
callback(new customError("text is not a string","apierror"));
return;
}
//check if text is less than 100k chars
if(text.length > 100000)
{
callback({stop: "text must be less than 100k chars"});
callback(new customError("text must be less than 100k chars","apierror"));
return;
}
}