Custom error messages. #450

Open
trusktr opened this Issue Aug 16, 2013 · 0 comments

Comments

Projects
None yet
1 participant

trusktr commented Aug 16, 2013

It'd be nice to be able to set a custom error message in a property of the options object that get passed in to httpProxy.createServer(options);

The property could be called errorMessage and to make it work you'd only have to add a conditional test around line 303 of /lib/node-http-proxy.js and line 211 of /lib/node-http-proxy/http-proxy.js.

if (options.errorMessage != "" /*improve this test, but just for example*/) {
    res.end(options.errorMessage);
}
else {
    res.end('Internal Server Error');
}

Then we could do things like

var proxyServer = httpProxy.createServer({
    errorMessage = "Nothing here. Come back later...",
    ...
});

Personally, I'd take it further and also allow options.errorMessage to be a function that returns a string. This would allow the most imaginative people to do things like display error messages at random.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment