mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
Respond with 500 when an error occurs, instead of trying to use next which isn't part of the http.createServer callback
parent
cb3b2912e7
commit
daee868523
@ -8,7 +8,7 @@ var pg = require('pg');
|
||||
|
||||
var conString = "postgres://postgres:1234@localhost/postgres";
|
||||
|
||||
var server = http.createServer(function(req, res, next) {
|
||||
var server = http.createServer(function(req, res) {
|
||||
|
||||
// get a pg client from the connection pool
|
||||
pg.connect(conString, function(err, client, done) {
|
||||
@ -23,7 +23,8 @@ var server = http.createServer(function(req, res, next) {
|
||||
// In this case, if we have successfully, received a client (truthy)
|
||||
// then it will be removed from the pool.
|
||||
done(client);
|
||||
next(err);
|
||||
res.writeHead(500, {'content-type': 'text/html'});
|
||||
res.end('An error occurred');
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user