You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can parse that message with a regex to extract the code and everything, but I think it'd make more sense to have a few more fields that digest that information already (errno would probably be the most helpful, at least for my use case).
One could also take that a step further and introduce more classes that derive
I'd like to reiterate the necessity for this since parsing the error message is not a reliable solution: Just recently, the error messages changed, and as a consequence my regular expression did not match errno and sqlstate.
Luckily that code had not hit any production environment yet, but my app is evolving in a way that I will have to handle database errors more and more. I'd highly appreciate a DatabaseError.errno: number field that I could rely on.
The report is specific enough that it could probably be turned into a small failing test for “Descriptive body for errors”. I would try to assert the exact behavior around UNIQUE rather than only checking that the command or UI path no longer errors, so the test guards the intended fix.
Activity
twiddler commentedon Feb 24, 2025
I'd like to reiterate the necessity for this since parsing the error message is not a reliable solution: Just recently, the error messages changed, and as a consequence my regular expression did not match
errnoandsqlstate.Luckily that code had not hit any production environment yet, but my app is evolving in a way that I will have to handle database errors more and more. I'd highly appreciate a
DatabaseError.errno: numberfield that I could rely on.Thank you. 🙏
hiSandog commentedon Jul 6, 2026
The report is specific enough that it could probably be turned into a small failing test for “Descriptive body for errors”. I would try to assert the exact behavior around
UNIQUErather than only checking that the command or UI path no longer errors, so the test guards the intended fix.