I really want to do something useful when a PK violation occurs but I hate trapping error numbers… they just don’t read right without comments (they’re certainly not self documenting).
I know I can find all the potential error numbers at SQL Server books online but I really want to be able to pass the error number to some helper class or look it up against a Dictionary of some sort rather than have non-descript err numbers everywhere.
Has anyone got / seen any code anywhere that encapsulates the SQL Server Error numbers in this way as I don’t want to re-invent the wheel (or I’m lazy maybe).
If you use TRY/CATCH in SQL Server then when you rethrow the error it’s always 50000 anyway.
Where are the error numbers coming from? LINQ? ORM? Embedded SQL? Stored procs?