code: function sendError(res, obj, code, internalCode) {
  	if (code) {
  		obj.code = code;
  	}
  	if (!res) {
  		if (internalCode !== undefined) {
  			obj.reason += ' { internalCode: ' + internalCode + ' }';
  		}
  		return obj;
  	}
  	if (internalCode !== undefined) {
  		obj.internalCode = internalCode;
  	}
  
  	try {
  		if (!res.headersSent) {
  			res.status(code);
  		}
  		return res.send(obj);
  	}
  	catch(e) {
  		console.error('swagger.respond sendError:', e, 'headersSent', res.headersSent);
  		if (res && res.status(code)) {
  			res.end(JSON.stringify(obj));
  		}
  	}
  }
docs: Sends an error down to the client. This is designed to be used by 'sendSPrintFError' and 'sendStringError'. Only use
  this if you know what you're up to, sir. :)
  @param res Optional Express Response object.
  @param obj The partially composed JSON response.
  @param code The HTTP Status code to send (like 404, 403, etc).
  @param internalCode An optional internal code to also send to the client. This is useful for programmatic use of the API so we can do non-string-based comparisons.
  @return {*} If no res is provided, the error JSON object will be returned; otherwise, the results of res.send are returned.