|
16 | 16 | Err: errors.New("error reading input"), |
17 | 17 | } |
18 | 18 | errorWorkingTreeNotClean = GutError{ |
19 | | - Message: "I can't continue further because the working tree is not clean", |
| 19 | + Message: "I can't continue further because the working tree is not clean. Commit your changes with gut save", |
20 | 20 | Code: 2, |
21 | 21 | Err: errors.New("working tree not clean"), |
22 | 22 | } |
@@ -56,17 +56,21 @@ func getLinkForError(GutError GutError) string { |
56 | 56 | // |
57 | 57 | // This should be used when the error is known and can be resolved by the user |
58 | 58 | func exitOnKnownError(typeOfError GutError, err error) { |
| 59 | + |
| 60 | + // When the error is linked to the user input, we don't print the error message |
| 61 | + // because it's not useful |
| 62 | + if typeOfError.Code == 1 { |
| 63 | + os.Exit(1) |
| 64 | + return |
| 65 | + } |
59 | 66 | // Print the error message to stderr |
60 | 67 | fmt.Fprintln(os.Stderr, "") |
61 | 68 | if err != nil { |
62 | 69 | fmt.Fprintf(os.Stderr, color.RedString("%s (error: %s)\n"), color.RedString(typeOfError.Message), color.RedString(err.Error())) |
63 | | - /* print.Message("%s (error: %s)", print.Error, typeOfError.Message, err.Error()) */ |
64 | 70 | } else { |
65 | 71 | fmt.Fprintf(os.Stderr, "%s\n", color.RedString(typeOfError.Message)) |
66 | | - /* print.Message("%s", print.Error, typeOfError.Message) */ |
67 | 72 | } |
68 | 73 | fmt.Fprintf(os.Stderr, "To resolve this issue, please follow the instructions on this page: %s\n", getLinkForError(typeOfError)) |
69 | | - /* print.Message("To resolve this issue, please follow the instructions on this page: %s", print.Optional, getLinkForError(typeOfError)) */ |
70 | 74 |
|
71 | 75 | os.Exit(1) |
72 | 76 | } |
0 commit comments