Repository navigation
Conversation
Adds NpgsqlException.Code with a basic NpgsqlErrorCode enum. Currently covers PG exceptions and ConnectionPoolExhausted. Closes npgsql#4544
3f6c513 to
6698a41
Compare
After thinking about it, I 100% agree. Ideally all information about error conditions would get conveyed via SqlState.
No, I also cannot find "some code-space reserved for drivers" but perhaps your "whatever" part is a solution. Looking how some ODBC drivers report the fact that they ran out of connection handles, HY014 seems like something one could (ab)use to communicate the fact that the pool was exhausted (given the fact, that a "proper" implementation of a spec that was written for C in the 90ies will probably never happen in .NET in any case). What do you think? |
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