Skip to content

Commit

Permalink
Fixing error types
Browse files Browse the repository at this point in the history
  • Loading branch information
acrodrig committed Oct 21, 2024
1 parent 96bea4b commit 77bd336
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
"include": ["src/", "test/"]
},
"imports": {
"@std/assert": "jsr:@std/assert@^1.0",
"@std/collections": "jsr:@std/collections@^1.0",
"@std/fmt": "jsr:@std/fmt@^1.0",
"@std/log": "jsr:@std/log@^0.224",
"schema": "npm:@types/json-schema/7.0.15",
"mysql/": "https://deno.land/x/[email protected]/",
"postgres/": "https://deno.land/x/[email protected]/",
"sqlite/": "https://deno.land/x/[email protected]/",
"@std/assert": "jsr:@std/assert@^0.226",
"@std/fmt": "jsr:@std/fmt@^0.225",
"@std/log": "jsr:@std/log@^0.224"
"sqlite/": "https://deno.land/x/[email protected]/"
},
"lock": false,
"tasks": {
Expand Down
8 changes: 4 additions & 4 deletions src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ export class DB {
// Need to await to be able to catch potential errors
return await DB.client.query(DB._sqlFilter(sql), parameters);
} catch (ex) {
if (TTY) DB.error(ex, sql, parameters);
this.logger.error({ method: "query", sql: clean(sql), parameters, error: ex.message, stack: ex.stack });
if (TTY) DB.error(ex as Error, sql, parameters);
this.logger.error({ method: "query", sql: clean(sql), parameters, error: (ex as Error).message, stack: (ex as Error).stack });
throw ex;
}
}
Expand All @@ -233,8 +233,8 @@ export class DB {
// Need to await to be able to catch potential errors
return DB.client.execute(DB._sqlFilter(sql), parameters);
} catch (ex) {
if (TTY) DB.error(ex, sql, parameters);
this.logger.error({ method: "execute", sql: clean(sql), parameters, error: ex.message, stack: ex.stack });
if (TTY) DB.error(ex as Error, sql, parameters);
this.logger.error({ method: "execute", sql: clean(sql), parameters, error: (ex as Error).message, stack: (ex as Error).stack });
throw ex;
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function dbInit(type: string, schemas?: Schema[]) {
if (schemas) await createTables(schemas);
} catch (ex) {
console.error("\n❌ Could not connect to DB '" + type + "' using 'dbx@" + hostname + "' or could not execute SQL!\n");
console.error("MESSAGE: " + ex.message + "");
console.error("MESSAGE: " + (ex as Error).message + "");
console.error("\nMake sure the user is created in the database (with NO password) and the DB is up\n");
Deno.exit(1);
}
Expand Down

0 comments on commit 77bd336

Please sign in to comment.