-
-
Notifications
You must be signed in to change notification settings - Fork 417
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
Error kind is private #571
Comments
Could you be more specific about what actions you want to take in response to errors? |
The application is a warp server. When I do |
I'd just use query_opt instead and avoid having to deal with figuring out which kind of error it is in the first place. |
Thank you |
I hope this issue reopened. This is not just about query_opt method. There are many cases when application need to take different action on different kind of errors. For example, application could terminate process when error is caused by syntax error but ignore error from closed connection, but currently there is no easy way to differentiate errors when cause is None. |
I found myself in the same situation as @hn-sl: we want to differentiate programming errors and connectivity/availability errors: I.e. I want the program to terminate if it is a programming error (wrong parameter type in a prepared query, Having access to the kind of en error, or at least having 'is_error_in_query' would help with that. |
On
tokio-postgres::error
,Kind
is a privateenum
as well as a private field insideErrorInner
.There is no way of asserting the error except for parsing the string that comes out of the
Display
implementation forError
For example:
In both line 455:
pub(crate) fn column(column: String)
and line 479:
pub(crate) fn row_count()
the errors are created with no cause, only kind. And the only way to extract that information and discern between the two is by comparing the output of the
Display
implementation.Am I missing something or not seeing a way to assess the error kind and take action accordingly?
The text was updated successfully, but these errors were encountered: