Sort packages by name in error messages

This commit is contained in:
2026-04-24 20:41:40 +03:00
parent 596d8753a7
commit 2f9487affe
2 changed files with 5 additions and 0 deletions
+1
View File
@@ -765,6 +765,7 @@ func removePackages() {
return return
} else if errors.As(err, &bpmlib.PackageRemovalDependencyErr{}) { } else if errors.As(err, &bpmlib.PackageRemovalDependencyErr{}) {
for pkg, dependants := range err.(bpmlib.PackageRemovalDependencyErr).RequiredPackages { for pkg, dependants := range err.(bpmlib.PackageRemovalDependencyErr).RequiredPackages {
slices.Sort(dependants)
fmt.Printf("The following packages depend on package (%s): %s\n", pkg, strings.Join(dependants, ", ")) fmt.Printf("The following packages depend on package (%s): %s\n", pkg, strings.Join(dependants, ", "))
} }
+4
View File
@@ -2,6 +2,7 @@ package bpmlib
import ( import (
"fmt" "fmt"
"slices"
"strings" "strings"
) )
@@ -10,6 +11,7 @@ type PackageNotFoundErr struct {
} }
func (e PackageNotFoundErr) Error() string { func (e PackageNotFoundErr) Error() string {
slices.Sort(e.packages)
return "The following packages were not found in any databases: " + strings.Join(e.packages, ", ") return "The following packages were not found in any databases: " + strings.Join(e.packages, ", ")
} }
@@ -18,6 +20,7 @@ type DependencyNotFoundErr struct {
} }
func (e DependencyNotFoundErr) Error() string { func (e DependencyNotFoundErr) Error() string {
slices.Sort(e.dependencies)
return "The following dependencies were not found in any databases: " + strings.Join(e.dependencies, ", ") return "The following dependencies were not found in any databases: " + strings.Join(e.dependencies, ", ")
} }
@@ -27,6 +30,7 @@ type PackageConflictErr struct {
} }
func (e PackageConflictErr) Error() string { func (e PackageConflictErr) Error() string {
slices.Sort(e.conflicts)
return fmt.Sprintf("Package (%s) is in conflict with the following packages: %s", e.pkg, strings.Join(e.conflicts, ", ")) return fmt.Sprintf("Package (%s) is in conflict with the following packages: %s", e.pkg, strings.Join(e.conflicts, ", "))
} }