vapor / postgres-nio

🐘 Non-blocking, event-driven Swift client for PostgreSQL.
https://api.vapor.codes/postgresnio/documentation/postgresnio/
MIT License
317 stars 72 forks source link

Make the PSQLError description more useful #354

Closed trasch closed 1 year ago

trasch commented 1 year ago

... by making it conform to CustomStringConvertible and CustomDebugStringConvertible.

Currently, print(error as! PSQLError) will print something like this: PSQLError(backing: PostgresNIO.PSQLError.(unknown context at $100aeb99c).Backing) which is not very helpful.

I would propose to add a description to PSQLError that uses some of the infos provided in .code, .serverInfo and other properties to convey a more helpfull message.

And I can tackle this myself, unless someone else wants to do it... 😄

fabianfett commented 1 year ago

Let's discuss here... And I'm happy for you to take it from there: https://github.com/vapor/postgres-nio/pull/356

trasch commented 1 year ago

This here suits me at least: https://github.com/Outdooractive/PostgresConnectionPool/blob/main/Sources/PostgresConnectionPool/Extensions/PSQLError%2BDescription.swift