Module dependencies
HTTPError
Hide Source
var HTTPError = require('httperror'),
util = require('util');
Module dependencies
var HTTPError = require('httperror'),
util = require('util');
Expose SolrError
module.exports = SolrError;
Create a new SolrError
function SolrError(req,res,htmlMessage){
var message = '';
if(htmlMessage){
var matches = htmlMessage.match(/<pre>([\s\S]+)<\/pre>/);
message = decode((matches || ['', htmlMessage])[1].trim());
}
HTTPError.call(this, req, res, message);
Error.captureStackTrace(this,arguments.callee);
this.name = 'SolrError';
}
util.inherits(SolrError, HTTPError);
Decode few HTML entities: &<>'"
function decode(str) {
return str.replace(/&/g,'&')
.replace(/</gm, '<')
.replace(/>/gm, '>')
.replace(/'/gm, '\'')
.replace(/"/gm, '"');
};