I guess you want to have the stack trace displayed on the client (which is ti be
avoided, since you may give away details of your system that might be exploited by
malicious users).
Anyway, this would do:
require("http").createServer(function (req, res) {
try {
xxx;
} catch(e) {
res.writeHead(500, { "Content-Type": "text/plain"});
res.write("Status: " + res.statusCode + "\n");
res.write("Message: " +e.message + "\n");
res.write("Stacktrace: " + e.stack + "\n");
res.end();
return;
}
res.writeHead(200, { "Content-Type": "text/plain"});
res.end("OK");
}).listen(8080, "127.0.0.1");
console.log("Server running at
http://127.0.0.1:8080/");
Regards,
Luca Morandini
Data Architect - AURIN project
Melbourne eResearch Group
Department of Computing and Information Systems
University of Melbourne
Tel. +61 03 903 58 380
Skype: lmorandini