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

Cast database errors to click exceptions for UX #1522

Merged
merged 5 commits into from
Sep 12, 2024
Merged

Conversation

sfc-gh-turbaszek
Copy link
Collaborator

Pre-review checklist

  • I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
  • I've added or updated automated unit tests to verify correctness of my new code.
  • I've added or updated integration tests to verify correctness of my new code.
  • I've confirmed that my changes are working by executing CLI's commands manually on MacOS.
  • I've confirmed that my changes are working by executing CLI's commands manually on Windows.
  • I've confirmed that my changes are up-to-date with the target branch.
  • I've described my changes in the release notes.
  • I've described my changes in the section below.

Changes description

Cast DatabaseError to ClickException. Before:

➜ snow sql -q "select foo"
select foo

An unexpected exception occurred. Use --debug option to see the traceback. Exception message:

000904 (42000): SQL compilation error: error line 1 at position 7
invalid identifier 'FOO'

and after

➜ snow sql -q "select foo"
select foo
╭─ Error ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ 000904 (42000): SQL compilation error: error line 1 at position 7                                                                                                                                            │
│ invalid identifier 'FOO'                                                                                                                                                                                     │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯


@sfc-gh-turbaszek sfc-gh-turbaszek requested a review from a team as a code owner September 2, 2024 07:54
sfc-gh-bdufour
sfc-gh-bdufour previously approved these changes Sep 12, 2024
Comment on lines +161 to +160
if isinstance(exception, DatabaseError):
return ClickException(exception.msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

Telemetry will then report this as a non-CLI error too, right?

Any thoughts on whether we should do something similar for ProgrammingError coming out of the connector?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Telemetry will then report this as a non-CLI error too, right?

That's correct, reporting happens before type casting. I think it's ok. We don't distinguish between expected and unexpected db errors.

ProgrammingError is a DatabaseError so it's already covered.

@sfc-gh-turbaszek sfc-gh-turbaszek merged commit 026f635 into main Sep 12, 2024
19 checks passed
@sfc-gh-turbaszek sfc-gh-turbaszek deleted the cast-sql-errors branch September 12, 2024 15:02
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.

3 participants