Skip to content

Commit

Permalink
log db connection errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tobinbradley committed Jul 8, 2022
1 parent 61df174 commit 5e9bcaf
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 12 deletions.
5 changes: 4 additions & 1 deletion routes/bbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ module.exports = function (fastify, opts, next) {
fastify.pg.connect(onConnect)

function onConnect(err, client, release) {
if (err) return reply.code(500).send({ "error": "Database Error"})
if (err) {
fastify.log.error(err)
return reply.code(500).send({ error: "Database connection error." })
}

client.query(
sql(request.params, request.query),
Expand Down
5 changes: 4 additions & 1 deletion routes/centroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ module.exports = function (fastify, opts, next) {
fastify.pg.connect(onConnect)

function onConnect(err, client, release) {
if (err) return reply.code(500).send({"error": "Database connection error."})
if (err) {
fastify.log.error(err)
return reply.code(500).send({ error: "Database connection error." })
}

client.query(sql(request.params, request.query), function onResult(
err,
Expand Down
5 changes: 4 additions & 1 deletion routes/geobuf.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ module.exports = function(fastify, opts, next) {
fastify.pg.connect(onConnect)

function onConnect(err, client, release) {
if (err) return reply.code(500).send({"error": "Database connection error."})
if (err) {
fastify.log.error(err)
return reply.code(500).send({ error: "Database connection error." })
}

client.query(sql(request.params, request.query), function onResult(
err,
Expand Down
5 changes: 4 additions & 1 deletion routes/geojson.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ module.exports = function (fastify, opts, next) {
fastify.pg.connect(onConnect)

function onConnect(err, client, release) {
if (err) return reply.code(500).send({"error": "Database connection error."})
if (err) {
fastify.log.error(err)
return reply.code(500).send({ error: "Database connection error." })
}

client.query(
sql(request.params, request.query),
Expand Down
5 changes: 4 additions & 1 deletion routes/intersect_feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ module.exports = function (fastify, opts, next) {
fastify.pg.connect(onConnect)

function onConnect(err, client, release) {
if (err) return reply.code(500).send({"error": "Database connection error."})
if (err) {
fastify.log.error(err)
return reply.code(500).send({ error: "Database connection error." })
}

client.query(
sql(request.params, request.query),
Expand Down
5 changes: 4 additions & 1 deletion routes/intersect_point.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ module.exports = function (fastify, opts, next) {
fastify.pg.connect(onConnect)

function onConnect(err, client, release) {
if (err) return reply.code(500).send({"error": "Database connection error."})
if (err) {
fastify.log.error(err)
return reply.code(500).send({ error: "Database connection error." })
}

client.query(
sql(request.params, request.query),
Expand Down
5 changes: 4 additions & 1 deletion routes/list_columns.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ module.exports = function (fastify, opts, next) {
fastify.pg.connect(onConnect)

function onConnect(err, client, release) {
if (err) return reply.code(500).send({"error": "Database connection error."})
if (err) {
fastify.log.error(err)
return reply.code(500).send({ error: "Database connection error." })
}

client.query(
sql(request.params),
Expand Down
5 changes: 4 additions & 1 deletion routes/list_tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ module.exports = function (fastify, opts, next) {
fastify.pg.connect(onConnect)

function onConnect(err, client, release) {
if (err) return reply.code(500).send({"error": "Database connection error."})
if (err) {
fastify.log.error(err)
return reply.code(500).send({"error": "Database connection error."})
}

client.query(
sql(request.params, request.query),
Expand Down
5 changes: 4 additions & 1 deletion routes/mvt.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ module.exports = function(fastify, opts, next) {
fastify.pg.connect(onConnect)

function onConnect(err, client, release) {
if (err) return reply.code(500).send({"error": "Database connection error."})
if (err) {
fastify.log.error(err)
return reply.code(500).send({ error: "Database connection error." })
}

client.query(sql(request.params, request.query), function onResult(
err,
Expand Down
5 changes: 4 additions & 1 deletion routes/nearest.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ module.exports = function (fastify, opts, next) {
fastify.pg.connect(onConnect)

function onConnect(err, client, release) {
if (err) return reply.code(500).send({"error": "Database connection error."})
if (err) {
fastify.log.error(err)
return reply.code(500).send({ error: "Database connection error." })
}

client.query(
sql(request.params, request.query),
Expand Down
5 changes: 4 additions & 1 deletion routes/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ module.exports = function (fastify, opts, next) {
fastify.pg.connect(onConnect)

function onConnect(err, client, release) {
if (err) return reply.code(500).send({"error": "Database connection error."})
if (err) {
fastify.log.error(err)
return reply.code(500).send({ error: "Database connection error." })
}

client.query(
sql(request.params, request.query),
Expand Down
5 changes: 4 additions & 1 deletion routes/transform_point.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ module.exports = function (fastify, opts, next) {
fastify.pg.connect(onConnect)

function onConnect(err, client, release) {
if (err) return reply.code(500).send({"error": "Database connection error."})
if (err) {
fastify.log.error(err)
return reply.code(500).send({ error: "Database connection error." })
}

client.query(
sql(request.params, request.query),
Expand Down

0 comments on commit 5e9bcaf

Please sign in to comment.