isFormattedCompilerError reports whether err is already a console-formatted compiler error produced by formatCompilerError, formatCompilerErrorWithPosition, or parser.FormatImportError. Use this instead of fragile string-contains checks to avoid double-wrapping.
(err error)
| 53 | // produced by formatCompilerError, formatCompilerErrorWithPosition, or parser.FormatImportError. |
| 54 | // Use this instead of fragile string-contains checks to avoid double-wrapping. |
| 55 | func isFormattedCompilerError(err error) bool { |
| 56 | var wce *wrappedCompilerError |
| 57 | if errors.As(err, &wce) { |
| 58 | return true |
| 59 | } |
| 60 | // Also detect errors from the parser package (e.g. FormatImportError) which are already |
| 61 | // console-formatted with source location and must not be re-wrapped. |
| 62 | var fpe *parser.FormattedParserError |
| 63 | return errors.As(err, &fpe) |
| 64 | } |
| 65 | |
| 66 | // formatCompilerErrorWithPosition creates a formatted compiler error with specific line/column position. |
| 67 | // |
no outgoing calls