-
Notifications
You must be signed in to change notification settings - Fork 78
Refine error wrapper heuristic #369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Refine error wrapper heuristic #369
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #369 +/- ##
==========================================
- Coverage 87.60% 87.47% -0.13%
==========================================
Files 73 73
Lines 10848 10864 +16
==========================================
Hits 9503 9503
- Misses 1155 1167 +12
- Partials 190 194 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
for sig, act := range _assumeReturns { | ||
if sig.match(pass, call) { | ||
return act(call) | ||
return act(call), true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trigger
's nilability implies this boolean value, right? shouldn't we just do that?
func IsError(pass *analysishelper.EnhancedPass, expr ast.Expr) bool { | ||
t := pass.TypesInfo.TypeOf(expr) | ||
if t == nil { | ||
return false | ||
} | ||
// Check if expr represents an implementation of the error interface | ||
return implementsError(t) | ||
} | ||
|
||
// implementsError checks if the given object implements the error interface. It also covers the case of | ||
// interfaces that embed the error interface. | ||
func implementsError(t types.Type) bool { | ||
if ErrorInterface == nil { | ||
return false | ||
} | ||
return types.Implements(t, ErrorInterface) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we attach these directly to analysishelper.EnhancedPass
such that we do not have to pass it around?
This PR refines the error wrapping heuristic to cover:
return NewInternalServerError("some error message")
)return Wrapf(Wrapf(Wrapf(NewError(err.Error()))))
)