mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 17:59:25 +00:00
Catch database errors and prevent them from crashing the app
This commit is contained in:
@@ -98,11 +98,20 @@ class DatabaseConnectionPool {
|
||||
const prepared = sql.includes('?');
|
||||
|
||||
let data;
|
||||
if (!prepared) {
|
||||
[ data ] = await this.#connectionPool.execute(sql);
|
||||
} else {
|
||||
[ data ] =
|
||||
await this.#connectionPool.execute(sql, params);
|
||||
try {
|
||||
if (!prepared) {
|
||||
[ data ] = await this.#connectionPool.execute(
|
||||
sql
|
||||
);
|
||||
} else {
|
||||
[ data ] = await this.#connectionPool.execute(
|
||||
sql,
|
||||
params
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
data = [];
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
Reference in New Issue
Block a user