MCPcopy
hub / github.com/MadAppGang/dingo / ErrorPropGenerator

Struct ErrorPropGenerator

pkg/codegen/error_prop.go:52–58  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

50// - Second: tmp1, err1
51// - Third: tmp2, err2
52type 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.
61func NewErrorPropGenerator(expr *ast.ErrorPropExpr, returnTypes []string) *ErrorPropGenerator {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected