Show meaningful MySQL errors when startup fails
This commit is contained in:
parent
e396219c03
commit
a3bd7fa779
2 changed files with 7 additions and 1 deletions
2
index.js
2
index.js
|
@ -34,7 +34,7 @@ let server = http.createServer(app);
|
|||
// Check if database needs upgrading before starting the server
|
||||
dbcheck(err => {
|
||||
if (err) {
|
||||
log.error('DB', err);
|
||||
log.error('DB', err.message || err);
|
||||
return process.exit(1);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -21,6 +21,12 @@ let db = mysql.createPool(mysqlConfig);
|
|||
function listTables(callback) {
|
||||
db.getConnection((err, connection) => {
|
||||
if (err) {
|
||||
if(err.code === 'ER_ACCESS_DENIED_ERROR'){
|
||||
err = new Error('Could not access the database. Check MySQL config and authentication credentials');
|
||||
}
|
||||
if(err.code === 'ECONNREFUSED' || err.code === 'PROTOCOL_SEQUENCE_TIMEOUT'){
|
||||
err = new Error('Could not connect to the database. Check MySQL host and port configuration');
|
||||
}
|
||||
return callback(err);
|
||||
}
|
||||
let query = 'SHOW TABLES';
|
||||
|
|
Loading…
Reference in a new issue