Skip to content

Commit d6701ac

Browse files
committed
Always panic on internal failures
These uses of `feedback.Error()` in the event of internal failures was a departure from the convention established in the rest of the code of using `feedback.Error()` only for failures resulting from external issues, and panic() for those resulting from internal issues (in which case the traceback is useful).
1 parent 5421e9f commit d6701ac

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

check/check.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package check
1818

1919
import (
2020
"fmt"
21-
"os"
2221

2322
"github.com/arduino/arduino-check/check/checkconfigurations"
2423
"github.com/arduino/arduino-check/check/checkdata"
@@ -40,8 +39,7 @@ func RunChecks(project project.Type) {
4039
for _, checkConfiguration := range checkconfigurations.Configurations() {
4140
runCheck, err := shouldRun(checkConfiguration, project)
4241
if err != nil {
43-
feedback.Errorf("Error while determining whether to run check: %v", err)
44-
os.Exit(1)
42+
panic(err)
4543
}
4644

4745
if !runCheck {

result/result.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@ import (
2121
"encoding/json"
2222
"fmt"
2323
"html/template"
24-
"os"
2524

2625
"github.com/arduino/arduino-check/check/checkconfigurations"
2726
"github.com/arduino/arduino-check/check/checklevel"
2827
"github.com/arduino/arduino-check/check/checkresult"
2928
"github.com/arduino/arduino-check/configuration"
3029
"github.com/arduino/arduino-check/configuration/checkmode"
3130
"github.com/arduino/arduino-check/project"
32-
"github.com/arduino/arduino-check/result/feedback"
3331
"github.com/arduino/go-paths-helper"
3432
)
3533

@@ -95,8 +93,7 @@ func (results *Type) Initialize() {
9593
func (results *Type) Record(checkedProject project.Type, checkConfiguration checkconfigurations.Type, checkResult checkresult.Type, checkOutput string) string {
9694
checkLevel, err := checklevel.CheckLevel(checkConfiguration, checkResult)
9795
if err != nil {
98-
feedback.Errorf("Error while determining check level: %v", err)
99-
os.Exit(1)
96+
panic(fmt.Errorf("Error while determining check level: %v", err))
10097
}
10198

10299
summaryText := fmt.Sprintf("Check %s result: %s", checkConfiguration.ID, checkResult)

0 commit comments

Comments
 (0)