Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2023-09-04 09:24:31 +02:00
parent 4912292503
commit 814feeed73
19 changed files with 75 additions and 38 deletions
@@ -69,7 +69,7 @@ export type DatabaseTaskStoreOptions = {
};
/**
* Typeguard to help DatabaseTaskStore understand when database is PluginDatabaseManager vs. when database is a Knex instance.
* Type guard to help DatabaseTaskStore understand when database is PluginDatabaseManager vs. when database is a Knex instance.
*
* * @public
*/
@@ -81,7 +81,13 @@ function isPluginDatabaseManager(
const parseSqlDateToIsoString = <T>(input: T): T | string => {
if (typeof input === 'string') {
return DateTime.fromSQL(input, { zone: 'UTC' }).toISO();
const parsed = DateTime.fromSQL(input, { zone: 'UTC' });
if (!parsed.isValid) {
throw new Error(
`Failed to parse database timestamp '${input}', ${parsed.invalidReason}: ${parsed.invalidExplanation}`,
);
}
return parsed.toISO()!;
}
return input;