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.
I am trying to catch exceptions when inserting duplicates that violate a
UNIQUE
constraint. Node prints the exception asconsole.log(e)
gives meI 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
database-js/src/index.ts
Line 15 in f62005c
Also
code: 'UNKNOWN'
seems a bit odd, unless it does not describe any ofcode
,errno
orsqlstate
.The text was updated successfully, but these errors were encountered: