Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

util: simplify error creation #163

Merged
merged 1 commit into from
Dec 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions util/analyze_output_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (r ListAnalyzeResult) OutputText(resultType string) error {
analysis, valid := r.Analysis.([]string)
if !valid {
logrus.Error("Unexpected structure of Analysis. Should be of type []string")
return errors.New(fmt.Sprintf("Could not output %s analysis result", r.AnalyzeType))
return fmt.Errorf("Could not output %s analysis result", r.AnalyzeType)
}
r.Analysis = analysis

Expand All @@ -58,7 +58,7 @@ func (r MultiVersionPackageAnalyzeResult) OutputStruct() interface{} {
analysis, valid := r.Analysis.(map[string]map[string]PackageInfo)
if !valid {
logrus.Error("Unexpected structure of Analysis. Should be of type map[string]map[string]PackageInfo")
return errors.New(fmt.Sprintf("Could not output %s analysis result", r.AnalyzeType))
return fmt.Errorf("Could not output %s analysis result", r.AnalyzeType)
}
analysisOutput := getMultiVersionPackageOutput(analysis)
output := struct {
Expand All @@ -77,7 +77,7 @@ func (r MultiVersionPackageAnalyzeResult) OutputText(resultType string) error {
analysis, valid := r.Analysis.(map[string]map[string]PackageInfo)
if !valid {
logrus.Error("Unexpected structure of Analysis. Should be of type map[string]map[string]PackageInfo")
return errors.New(fmt.Sprintf("Could not output %s analysis result", r.AnalyzeType))
return fmt.Errorf("Could not output %s analysis result", r.AnalyzeType)
}
analysisOutput := getMultiVersionPackageOutput(analysis)

Expand All @@ -100,7 +100,7 @@ func (r SingleVersionPackageAnalyzeResult) OutputStruct() interface{} {
analysis, valid := r.Analysis.(map[string]PackageInfo)
if !valid {
logrus.Error("Unexpected structure of Analysis. Should be of type map[string]PackageInfo")
return errors.New(fmt.Sprintf("Could not output %s analysis result", r.AnalyzeType))
return fmt.Errorf("Could not output %s analysis result", r.AnalyzeType)
}
analysisOutput := getSingleVersionPackageOutput(analysis)
output := struct {
Expand All @@ -119,7 +119,7 @@ func (r SingleVersionPackageAnalyzeResult) OutputText(diffType string) error {
analysis, valid := r.Analysis.(map[string]PackageInfo)
if !valid {
logrus.Error("Unexpected structure of Analysis. Should be of type map[string]PackageInfo")
return errors.New(fmt.Sprintf("Could not output %s analysis result", r.AnalyzeType))
return fmt.Errorf("Could not output %s analysis result", r.AnalyzeType)
}
analysisOutput := getSingleVersionPackageOutput(analysis)

Expand Down
8 changes: 4 additions & 4 deletions util/diff_output_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (r MultiVersionPackageDiffResult) OutputStruct() interface{} {
diff, valid := r.Diff.(MultiVersionPackageDiff)
if !valid {
logrus.Error("Unexpected structure of Diff. Should follow the MultiVersionPackageDiff struct")
return errors.New(fmt.Sprintf("Could not output %s diff result", r.DiffType))
return fmt.Errorf("Could not output %s diff result", r.DiffType)
}

diffOutput := struct {
Expand All @@ -56,7 +56,7 @@ func (r MultiVersionPackageDiffResult) OutputText(diffType string) error {
diff, valid := r.Diff.(MultiVersionPackageDiff)
if !valid {
logrus.Error("Unexpected structure of Diff. Should follow the MultiVersionPackageDiff struct")
return errors.New(fmt.Sprintf("Could not output %s diff result", r.DiffType))
return fmt.Errorf("Could not output %s diff result", r.DiffType)
}

strPackages1 := stringifyPackages(getMultiVersionPackageOutput(diff.Packages1))
Expand Down Expand Up @@ -102,7 +102,7 @@ func (r SingleVersionPackageDiffResult) OutputStruct() interface{} {
diff, valid := r.Diff.(PackageDiff)
if !valid {
logrus.Error("Unexpected structure of Diff. Should follow the PackageDiff struct")
return errors.New(fmt.Sprintf("Could not output %s diff result", r.DiffType))
return fmt.Errorf("Could not output %s diff result", r.DiffType)
}

diffOutput := struct {
Expand All @@ -122,7 +122,7 @@ func (r SingleVersionPackageDiffResult) OutputText(diffType string) error {
diff, valid := r.Diff.(PackageDiff)
if !valid {
logrus.Error("Unexpected structure of Diff. Should follow the PackageDiff struct")
return errors.New(fmt.Sprintf("Could not output %s diff result", r.DiffType))
return fmt.Errorf("Could not output %s diff result", r.DiffType)
}

strPackages1 := stringifyPackages(getSingleVersionPackageOutput(diff.Packages1))
Expand Down