Commit dd75d750 authored by nanahira's avatar nanahira

add error handling for battle history query

parent 5b0235e3
...@@ -1776,6 +1776,11 @@ router.get('/history', function (req, res) { ...@@ -1776,6 +1776,11 @@ router.get('/history', function (req, res) {
console.log(sql); console.log(sql);
client.query(sql, function (err, result) { client.query(sql, function (err, result) {
if (err) {
return console.error('error running query', sql, err);
}
var total = result.rows[0].count var total = result.rows[0].count
var sql2 = `SELECT * from battle_history order by start_time desc limit ${page_num} offset ${offset}` var sql2 = `SELECT * from battle_history order by start_time desc limit ${page_num} offset ${offset}`
...@@ -1798,7 +1803,7 @@ router.get('/history', function (req, res) { ...@@ -1798,7 +1803,7 @@ router.get('/history', function (req, res) {
//call `done()` to release the client back to the pool //call `done()` to release the client back to the pool
done() done()
if (err) { if (err) {
return console.error('error running query', err) return console.error('error running query', sql2, err)
} }
res.json({ res.json({
total: total - 0, total: total - 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment