ReportError records a DSL error for reporting post DSL execution. It accepts a format and values a la fmt.Printf.
(fm string, vals ...any)
| 97 | // ReportError records a DSL error for reporting post DSL execution. It accepts |
| 98 | // a format and values a la fmt.Printf. |
| 99 | func ReportError(fm string, vals ...any) { |
| 100 | var suffix string |
| 101 | if cur := Context.Stack.Current(); cur != nil { |
| 102 | if name := cur.EvalName(); name != "" { |
| 103 | suffix = fmt.Sprintf(" in %s", name) |
| 104 | } |
| 105 | } else { |
| 106 | suffix = " (top level)" |
| 107 | } |
| 108 | err := fmt.Errorf(fm+suffix, vals...) |
| 109 | file, line := computeErrorLocation() |
| 110 | Context.Record(&Error{ |
| 111 | GoError: err, |
| 112 | File: file, |
| 113 | Line: line, |
| 114 | }) |
| 115 | } |
| 116 | |
| 117 | // IncompatibleDSL should be called by DSL functions when they are invoked in an |
| 118 | // incorrect context (e.g. "Params" in "Service"). |