MCPcopy Create free account
hub / github.com/bracesdev/errtrace / wrapExpr

Method wrapExpr

cmd/errtrace/main.go:986–1004  ·  view source on GitHub ↗
(n int, expr ast.Expr)

Source from the content-addressed store, hash-verified

984}
985
986func (t *walker) wrapExpr(n int, expr ast.Expr) {
987 switch {
988 case t.isErrtraceWrap(expr):
989 return // already wrapped
990
991 case isIdent(expr, "nil"):
992 // Optimization: ignore if it's "nil".
993 return
994 }
995
996 if t.optout(expr.Pos()) {
997 return
998 }
999
1000 *t.inserts = append(*t.inserts,
1001 &insertWrapOpen{N: n, Before: expr.Pos()},
1002 &insertWrapClose{After: expr.End()},
1003 )
1004}
1005
1006// Detects if an expression is in the form errtrace.Wrap(e) or errtrace.Wrap{n}(e).
1007func (t *walker) isErrtraceWrap(expr ast.Expr) bool {

Callers 3

returnStmtMethod · 0.95
deferStmtMethod · 0.95
wrapReturnCallMethod · 0.95

Calls 4

isErrtraceWrapMethod · 0.95
optoutMethod · 0.95
isIdentFunction · 0.85
PosMethod · 0.65

Tested by

no test coverage detected