G-5020: Never handle unnamed exceptions using the error number.
Critical
Maintainability
Reason
When literals are used for error numbers the reader needs the error message manual to unterstand what is going on. Commenting the code or using constants is an option, but it is better to use named exceptions instead, because it ensures a certain level of consistency which makes maintenance easier.
Example (bad)
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Example (good)
1 2 3 4 5 6 7 8 9 |
|