| 38 | } |
| 39 | |
| 40 | func (err *TaskfileDecodeError) Error() string { |
| 41 | buf := &bytes.Buffer{} |
| 42 | |
| 43 | // Print the error message |
| 44 | if err.Message != "" { |
| 45 | fmt.Fprintln(buf, color.RedString("err: %s", err.Message)) |
| 46 | } else { |
| 47 | // Extract the errors from the TypeError |
| 48 | te := &yaml.TypeError{} |
| 49 | if errors.As(err.Err, &te) { |
| 50 | if len(te.Errors) > 1 { |
| 51 | fmt.Fprintln(buf, color.RedString("errs:")) |
| 52 | for _, message := range te.Errors { |
| 53 | fmt.Fprintln(buf, color.RedString("- %s", message)) |
| 54 | } |
| 55 | } else { |
| 56 | fmt.Fprintln(buf, color.RedString("err: %s", te.Errors[0])) |
| 57 | } |
| 58 | } else { |
| 59 | // Otherwise print the error message normally |
| 60 | fmt.Fprintln(buf, color.RedString("err: %s", err.Err)) |
| 61 | } |
| 62 | } |
| 63 | fmt.Fprintln(buf, color.RedString("file: %s:%d:%d", err.Location, err.Line, err.Column)) |
| 64 | fmt.Fprint(buf, err.Snippet) |
| 65 | return buf.String() |
| 66 | } |
| 67 | |
| 68 | func (err *TaskfileDecodeError) Debug() string { |
| 69 | const indentWidth = 2 |