var sprintf = require('sprintf').sprintf;

var StopError = require('util/flow-ctrl').StopError;

function returnError(res, code, msg) {
  var headers;
  msg = msg || '';

  headers = { 
    'Content-Length': msg.length,
    'Connection': 'close'
  };

  res.writeHead(code, headers);
  res.end(msg);

  throw new StopError(sprintf('%d - %s', code, msg));
}
}

exports.returnError = returnError;

@@ -36,16 +36,63 @@
 rintf;%0A%0A
+var httpConstants = require('http/constants');%0A
 var Stop
@@ -224,17 +224,16 @@
 ders = %7B
- 
 %0A    'Co
@@ -400,42 +400,709 @@
 ;%0A%7D%0A
-%7D%0A%0Aexports.returnError = returnError
+%0Afunction verifyRequiredParams(req, res, requiredParams, type) %7B%0A  var validTypes = %5B 'querystring' %5D;%0A  var i, param, paramsLen, paramValue;%0A  var missingParams = %5B%5D;%0A  type = type %7C%7C 'querystring';%0A%0A  if (validTypes.indexOf(type) === -1) %7B%0A    throw new Error(sprintf('Invalid type: %25s', type));%0A  %7D%0A%0A  for (i = 0, paramsLen = requiredParams.length; i %3C paramsLen; i++) %7B%0A    param = requiredParams%5Bi%5D;%0A%0A    if (req.param(param, null) === null) %7B%0A      returnError(res, httpConstants.MISSING_PARAM_STATUS_CODES%5Bparam%5D,%0A                  sprintf('Missing required parameter: %25s', param));%0A      return;%0A    %7D%0A  %7D%0A%7D%0A%0Aexports.returnError = returnError;%0Aexports.verifyRequiredParams = verifyRequiredParams
 ;%0A

Add verifyRequiredParams method.