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:
@@ -99,13 +99,18 @@ class TestTemplate {
|
||||
|
||||
const conn = await new DatabaseConnectionPool();
|
||||
|
||||
await conn.runQuery(sql, [
|
||||
const result = await conn.runQuery(sql, [
|
||||
id,
|
||||
this.id,
|
||||
c.id,
|
||||
epochDate
|
||||
]);
|
||||
|
||||
conn.close();
|
||||
|
||||
if (!result.length)
|
||||
throw new Error('Could not assign class');
|
||||
|
||||
return new Test(id);
|
||||
}
|
||||
|
||||
@@ -130,13 +135,18 @@ class TestTemplate {
|
||||
(?, ?, ?, ?);
|
||||
`;
|
||||
|
||||
await conn.runQuery(sql, [
|
||||
const result = await conn.runQuery(sql, [
|
||||
id,
|
||||
a.id,
|
||||
name,
|
||||
maxMark
|
||||
]);
|
||||
|
||||
conn.close();
|
||||
|
||||
if (!result)
|
||||
throw new Error('Could not create test template');
|
||||
|
||||
return new TestTemplate(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user