formatCompilerError creates a formatted compiler error at line 1, column 1. Use this when the exact source position is unknown; IDE tooling can still navigate to the file. Use formatCompilerErrorWithPosition when a specific line/column is available. When cause is a *WorkflowValidationError with Line
(filePath string, errType string, message string, cause error)
| 32 | // message: the error message text |
| 33 | // cause: optional underlying error to wrap (use nil for validation errors) |
| 34 | func formatCompilerError(filePath string, errType string, message string, cause error) error { |
| 35 | line, column := 1, 1 |
| 36 | // Promote precise source location from WorkflowValidationError when available so that |
| 37 | // the emitted "file:line:col: error:" prefix points directly at the problematic field |
| 38 | // rather than always defaulting to line 1, column 1. |
| 39 | var vErr *WorkflowValidationError |
| 40 | if errors.As(cause, &vErr) && vErr.Line > 0 { |
| 41 | line = vErr.Line |
| 42 | if vErr.Column > 0 { |
| 43 | column = vErr.Column |
| 44 | } |
| 45 | if vErr.File != "" { |
| 46 | filePath = vErr.File |
| 47 | } |
| 48 | } |
| 49 | return formatCompilerErrorWithPosition(filePath, line, column, errType, message, cause) |
| 50 | } |
| 51 | |
| 52 | // isFormattedCompilerError reports whether err is already a console-formatted compiler error |
| 53 | // produced by formatCompilerError, formatCompilerErrorWithPosition, or parser.FormatImportError. |