Add infrastructure for Npgsql error codes #4580
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds NpgsqlException.Code with a basic NpgsqlErrorCode enum. Currently covers PG exceptions and ConnectionPoolExhausted only, we can incrementally add more codes as they're requested (we default to Other).
I don't love this.. Specifically the fact that PostgresException inherits the Code property (since it extends NpgsqlException), so people will likely think that's the interesting property; but it isn't (SqlState is). Ideally there would be some code-space reserved for drivers or whatever in SqlState, so we could allocate codes there and just promote SqlState to be on NpgsqlException... But I can't see anything like that, and it's beter not to mess with it.
@Brar we discussed this at some point, let me know what you think (@vonzshik @NinoFloris too).
Closes #4544