improve error message

This commit is contained in:
André Roth
2024-10-05 19:49:33 +02:00
parent ce2966e547
commit 75ca51b23b
5 changed files with 7 additions and 7 deletions

View File

@@ -218,7 +218,7 @@ func ImportPackageFiles(list *PackageList, packageFiles []string, forceReplace b
err = list.Add(p)
if err != nil {
reporter.Warning("Unable to add package to repo %s: %s", p, err)
reporter.Warning("Unable to add package: %s", err)
failedFiles = append(failedFiles, file)
continue
}

View File

@@ -138,7 +138,7 @@ func (l *PackageList) Add(p *Package) error {
existing, ok := l.packages[key]
if ok {
if !existing.Equals(p) {
return &PackageConflictError{fmt.Errorf("conflict in package %s", p)}
return &PackageConflictError{fmt.Errorf("package already exists and is different: %s", p)}
}
return nil
}
@@ -201,7 +201,7 @@ func (l *PackageList) Append(pl *PackageList) error {
existing, ok := l.packages[k]
if ok {
if !existing.Equals(p) {
return fmt.Errorf("conflict in package %s", p)
return fmt.Errorf("package already exists and is different: %s", p)
}
} else {
l.packages[k] = p

View File

@@ -131,7 +131,7 @@ func (s *PackageListSuite) TestAddLen(c *C) {
c.Check(s.list.Len(), Equals, 1)
c.Check(s.list.Add(s.p3), IsNil)
c.Check(s.list.Len(), Equals, 2)
c.Check(s.list.Add(s.p4), ErrorMatches, "conflict in package.*")
c.Check(s.list.Add(s.p4), ErrorMatches, "package already exists and is different: .*")
}
func (s *PackageListSuite) TestRemove(c *C) {
@@ -243,7 +243,7 @@ func (s *PackageListSuite) TestAppend(c *C) {
list.Add(s.p4)
err = s.list.Append(list)
c.Check(err, ErrorMatches, "conflict.*")
c.Check(err, ErrorMatches, "package already exists and is different: .*")
s.list.PrepareIndex()
c.Check(func() { s.list.Append(s.il) }, Panics, "Append not supported when indexed")

View File

@@ -65,7 +65,7 @@ func (s *PackageRefListSuite) TestNewPackageListFromRefList(c *C) {
list, err := NewPackageListFromRefList(reflist, coll, nil)
c.Assert(err, IsNil)
c.Check(list.Len(), Equals, 4)
c.Check(list.Add(s.p4), ErrorMatches, "conflict in package.*")
c.Check(list.Add(s.p4), ErrorMatches, "package already exists and is different: .*")
list, err = NewPackageListFromRefList(nil, coll, nil)
c.Assert(err, IsNil)

View File

@@ -1,5 +1,5 @@
Loading packages...
[!] Unable to add package to repo pyspi_0.6.1-1.3_source: conflict in package pyspi_0.6.1-1.3_source
[!] Unable to add package: package already exists and is different: pyspi_0.6.1-1.3_source
[!] Some files were skipped due to errors:
/pyspi_0.6.1-1.3.conflict.dsc
ERROR: some files failed to be added