Skip to content

Make PSQLError public #342

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

Merged
merged 2 commits into from
Apr 20, 2023
Merged

Conversation

fabianfett
Copy link
Collaborator

Motivation

Users want to inspect what has gone wrong. For this they need access to the error type that we throw.

Changes

  • Rewrite PSQLError to ensure it is a type that we can evolve in public
    • For this to work we shouldn't use associated types on the code enum
  • Merge channel and connectionError code into one
  • Rename PSQLDecodingError to PostgresMessageDecodingError to ensure a clear distinction to PostgresDecodingError
  • PSQLError is now a CoW type
  • Attach the query, if we have one to the PSQLError to make debugging easier

Result

  • Better debuggable errors.

Copy link
Member

@gwynne gwynne left a comment

Choose a reason for hiding this comment

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

Looks fine, but one nit: If you missed any other uses of #file (I dunno if you did, I didn't look), might as well change the rest to #fileID too (or #filePath if used within XCTest stuff) so there isn't any inconsistency.

@fabianfett fabianfett marked this pull request as ready for review April 20, 2023 08:36
@codecov-commenter
Copy link

codecov-commenter commented Apr 20, 2023

Codecov Report

Merging #342 (1a057b0) into main (f21252b) will decrease coverage by 0.38%.
The diff coverage is 30.40%.

❗ Current head 1a057b0 differs from pull request most recent head 12bebe8. Consider uploading reports for the commit 12bebe8 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #342      +/-   ##
==========================================
- Coverage   41.57%   41.19%   -0.38%     
==========================================
  Files         115      115              
  Lines        9434     9600     +166     
==========================================
+ Hits         3922     3955      +33     
- Misses       5512     5645     +133     
Impacted Files Coverage Δ
Sources/PostgresNIO/Postgres+PSQLCompat.swift 0.00% <0.00%> (ø)
...es/PostgresNIO/Connection/PostgresConnection.swift 16.63% <3.84%> (-0.70%) ⬇️
...urces/PostgresNIO/New/PostgresChannelHandler.swift 61.14% <33.33%> (ø)
Sources/PostgresNIO/New/PSQLError.swift 43.36% <34.03%> (-37.65%) ⬇️
...nection State Machine/ConnectionStateMachine.swift 57.63% <80.00%> (+0.01%) ⬆️
...ion State Machine/AuthenticationStateMachine.swift 49.18% <100.00%> (ø)
...ostgresNIO/New/PostgresBackendMessageDecoder.swift 94.02% <100.00%> (ø)

@fabianfett fabianfett merged commit 18a60ef into vapor:main Apr 20, 2023
@fabianfett fabianfett deleted the ff-public-psqlerror branch April 20, 2023 09:10
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