ErrorPropGenerator generates Go code for error propagation expressions (expr?). Basic Transforms: let data = readFile(path)? Into: tmp, err := readFile(path) if err != nil { return zeroVal1, zeroVal2, ..., err } data := tmp Context Transform (? "message"): let order = fetchOrder(id)
| 50 | // - Second: tmp1, err1 |
| 51 | // - Third: tmp2, err2 |
| 52 | type ErrorPropGenerator struct { |
| 53 | *BaseGenerator |
| 54 | Expr *ast.ErrorPropExpr |
| 55 | ReturnTypes []string // Zero values for non-error return types |
| 56 | Counter int // For generating unique variable names |
| 57 | NeedsFmt bool // Set to true if fmt.Errorf is generated (caller should add import) |
| 58 | } |
| 59 | |
| 60 | // NewErrorPropGenerator creates a new error propagation code generator. |
| 61 | func NewErrorPropGenerator(expr *ast.ErrorPropExpr, returnTypes []string) *ErrorPropGenerator { |
nothing calls this directly
no outgoing calls
no test coverage detected