Skip to content
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

db: Better error messages when querying remote #10636

Merged
merged 7 commits into from
Apr 1, 2024

Conversation

bholmesdev
Copy link
Contributor

@bholmesdev bholmesdev commented Apr 1, 2024

Changes

Introduce well-formatted errors for remote db client exceptions.

  • Add AstroDbError class to set "Astro DB Error" as the error name instead of AstroUserError.
  • Format an error message using the expected error "code" and "details" from Studio.
  • Special case "no such table" issues to show a hint to push the latest schema changes.
  • Misc: fix "unhandled promise rejection" getting logged for eager seeding by adding a .catch() with manual logging.

Before

image

After

Suspected "missing db push" errors:

image

General SQLite errors:

image

Testing

Docs

Copy link

changeset-bot bot commented Apr 1, 2024

🦋 Changeset detected

Latest commit: 5612902

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

`(Code ${error.code}) \nError querying remote database.`;
let hint = `See the Astro DB guide for query and push instructions: https://docs.astro.build/en/guides/astro-db/#query-your-database`;
if (error.code === KNOWN_ERROR_CODES.SQL_QUERY_FAILED && details.includes('no such table')) {
hint = `Did you run \`astro db push\` to push your latest table schemas?`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice addition

@bholmesdev bholmesdev merged commit 504d15d into main Apr 1, 2024
13 checks passed
@bholmesdev bholmesdev deleted the fix/bad-request-execute-before-push branch April 1, 2024 21:02
@astrobot-houston astrobot-houston mentioned this pull request Apr 1, 2024
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.

2 participants