-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isDbError() does not work #12400
Labels
Comments
Repo with repro: https://github.com/abegehr/astro-issue-12400-repro (since StackBlitz doesn't support Astro.clientAddress) |
I've implemented a work-around guard for this: export function isLibsqlError(err: unknown): err is LibsqlError {
if (!err || !(err instanceof Error)) return false;
const value = err as LibsqlError;
return (
typeof value.code === "string" &&
(value.rawCode === undefined || typeof value.rawCode === "number")
);
} |
I can reproduce it locally. |
ematipico
added
- P3: minor bug
An edge case that only affects very specific usage (priority)
pkg: db
and removed
needs triage
Issue needs to be triaged
labels
Nov 11, 2024
@abegehr would you like to send a PR with your fix? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
isDbError(err)
is false, even though the error is a LibsqlErrorSQLITE_CONSTRAINT_UNIQUE
thrown fromdb.insert
function in an Astro action.Notice: the StackBlitz repro works only locally, since StackBlitz doesn't support Astro.clientAddress: #6451 (comment)
What's the expected result?
I would expect to be able to identify Libsql errors thrown from inserting into db with astro.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-ofpscu-cwqc8l?file=src%2Factions%2Findex.ts
Participation
The text was updated successfully, but these errors were encountered: