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

Method wrapReturnCall

cmd/errtrace/main.go:955–984  ·  view source on GitHub ↗
(n int, ret *ast.ReturnStmt)

Source from the content-addressed store, hash-verified

953}
954
955func (t *walker) wrapReturnCall(n int, ret *ast.ReturnStmt) {
956 // Common validation
957 switch {
958 case len(t.errorIndices) != 1:
959 t.logf(ret.Pos(), "skipping function with multiple error returns")
960 return
961 case t.errorIndices[0] != t.numReturns-1:
962 t.logf(ret.Pos(), "skipping function with non-final error return")
963 return
964 case t.isErrtraceWrap(ret.Results[0]):
965 return
966 case t.optout(ret.Pos()):
967 return
968 }
969
970 if t.opts.NoWrapN {
971 *t.inserts = append(*t.inserts,
972 &insertReturnNBlockStart{N: n, Before: ret.Pos(), SkipReturn: ret.Results[0].Pos()},
973 &insertReturnNBlockClose{N: n, After: ret.End()},
974 )
975 return
976 }
977
978 if n > 6 {
979 t.logf(ret.Pos(), "skipping function with too many return values")
980 return
981 }
982
983 t.wrapExpr(n, ret.Results[0])
984}
985
986func (t *walker) wrapExpr(n int, expr ast.Expr) {
987 switch {

Callers 1

returnStmtMethod · 0.95

Calls 5

logfMethod · 0.95
isErrtraceWrapMethod · 0.95
optoutMethod · 0.95
wrapExprMethod · 0.95
PosMethod · 0.65

Tested by

no test coverage detected