Skip to content

Commit c09c82d

Browse files
committed
Use clear and consistent error output
Previously, it was not always clear that the error messages were such. Adding a prefix to the feedback.Error*() output ensures this will be clear and that the error messages will follow a consistent format.
1 parent ef27958 commit c09c82d

File tree

6 files changed

+9
-8
lines changed

6 files changed

+9
-8
lines changed

Diff for: check/checkdata/library.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func InitializeForLibrary(project project.Type, schemasPath *paths.Path) {
6262
url := "http://downloads.arduino.cc/libraries/library_index.json"
6363
httpResponse, err := http.Get(url)
6464
if err != nil {
65-
feedback.Errorf("%s Unable to download Library Manager index from %s", err, url)
65+
feedback.Errorf("Unable to download Library Manager index from %s: %s", err, url)
6666
os.Exit(1)
6767
}
6868
defer httpResponse.Body.Close()

Diff for: command/command.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
// ArduinoCheck is the root command function.
3434
func ArduinoCheck(rootCommand *cobra.Command, cliArguments []string) {
3535
if err := configuration.Initialize(rootCommand.Flags(), cliArguments); err != nil {
36-
feedback.Errorf("Configuration error: %v", err)
36+
feedback.Errorf("Invalid configuration: %v", err)
3737
os.Exit(1)
3838
}
3939

Diff for: configuration/configuration.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func Initialize(flags *pflag.FlagSet, projectPaths []string) error {
107107
targetPath := paths.New(projectPath)
108108
targetPathExists, err := targetPath.ExistCheck()
109109
if err != nil {
110-
return fmt.Errorf("Problem processing PROJECT_PATH argument value %v: %v", targetPath, err)
110+
return fmt.Errorf("Unable to process PROJECT_PATH argument value %v: %v", targetPath, err)
111111
}
112112
if !targetPathExists {
113113
return fmt.Errorf("PROJECT_PATH argument %v does not exist", targetPath)

Diff for: project/project.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func findProjects(targetPath *paths.Path) ([]Type, error) {
8888
return foundProjects, nil
8989
}
9090

91-
return nil, fmt.Errorf("specified path %s is not an Arduino project", targetPath)
91+
return nil, fmt.Errorf("Specified path %s is not an Arduino project", targetPath)
9292
}
9393

9494
if configuration.SuperprojectTypeFilter() == projecttype.All || configuration.Recursive() {
@@ -110,7 +110,7 @@ func findProjects(targetPath *paths.Path) ([]Type, error) {
110110
}
111111

112112
if foundProjects == nil {
113-
return nil, fmt.Errorf("no projects found under %s", targetPath)
113+
return nil, fmt.Errorf("No projects found under %s", targetPath)
114114
}
115115

116116
return foundProjects, nil

Diff for: result/feedback/feedback.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ func Errorf(format string, v ...interface{}) {
6666
Error(fmt.Sprintf(format, v...))
6767
}
6868

69-
// Error behaves like fmt.Print but adds a newline and also logs the error.
69+
// Error behaves like fmt.Print but adds a prefix, newline and also logs the error.
7070
func Error(v ...interface{}) {
71+
fmt.Fprint(os.Stderr, "error: ")
7172
fmt.Fprintln(os.Stderr, v...)
7273
logrus.Error(fmt.Sprint(v...))
7374
}

Diff for: result/result.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ func (results Type) WriteReport() error {
236236
if !reportFilePathParentExists {
237237
err = reportFilePath.Parent().MkdirAll()
238238
if err != nil {
239-
return fmt.Errorf("Error while creating report file path (%v): %v", reportFilePath.Parent(), err)
239+
return fmt.Errorf("Unable to create report file path (%v): %v", reportFilePath.Parent(), err)
240240
}
241241
}
242242

243243
err = reportFilePath.WriteFile(results.jsonReportRaw())
244244
if err != nil {
245-
return fmt.Errorf("Error while writing report: %v", err)
245+
return fmt.Errorf("While writing report: %v", err)
246246
}
247247

248248
return nil

0 commit comments

Comments
 (0)