Avoid Using Raw Strings in Error Handling #60
Sddilora
started this conversation in
Guidelines and How-To's
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Reasons to Avoid Using Raw Strings in Error Handling
Using raw strings in error handling, such as
err := errors.New("Dlr not found")
, is generally discouraged. Here are detailed reasons, including security considerations, for why predefined error variables are a better approach:1. Consistency
2. Maintainability
3. Readability
ErrorDlrNotFound
, are self-documenting and clearly convey the purpose of the error.4. Testing
5. Security Considerations
Controlled Information Disclosure
ErrorDlrNotFound
simply states that a dealer was not found without revealing internal details.Avoiding Injection Flaws
Centralized Management for Security Reviews
Consistent Logging and Monitoring
Beta Was this translation helpful? Give feedback.
All reactions