Don't require throw to add trace info for verbose mode by mmghv · Pull Request #1317 · TryGhost/node-sqlite3 · GitHub
Skip to content

Don't require throw to add trace info for verbose mode#1317

Merged
kewde merged 1 commit into
TryGhost:masterfrom
mmghv:verbose
Apr 28, 2020
Merged

Don't require throw to add trace info for verbose mode#1317
kewde merged 1 commit into
TryGhost:masterfrom
mmghv:verbose

Conversation

@mmghv

@mmghv mmghv commented Apr 27, 2020

Copy link
Copy Markdown
Contributor

Fixes #1316

Currently, verbose() adds trace info to the error object only if you throw the error by catching it inside a try/catch :

https://github.com/mapbox/node-sqlite3/blob/afa22076ba13ef3bc6afac892d9ed46a7ec36fc2/lib/trace.js#L18-L28

This doesn't work with promises as discussed in the linked issue because throwing in an async callback doesn't get caught by the promise or a wrapping try/catch.

this PR solves this issue by simply adding the trace info outside try/catch by checking the error object which is always the first argument.

@kewde

kewde commented Apr 27, 2020

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Verbose doesn't work with pormises

2 participants