Unify error messages

This commit is contained in:
2024-10-18 19:04:08 +02:00
parent 411cd89b7c
commit d4e7bce5e2
20 changed files with 92 additions and 110 deletions

View File

@@ -2,7 +2,6 @@ package atom
import (
"encoding/xml"
"errors"
"fmt"
"html"
)
@@ -29,17 +28,17 @@ func (c *Category) SetLabel(label string) {
// error.
func (c *Category) Check() error {
if c.Term == "" {
return errors.New("term attribute of category empty")
return fmt.Errorf("term attribute of category %v empty", c)
}
if c.Scheme != "" {
if !isValidIRI(c.Scheme) {
return fmt.Errorf("scheme attribute %v of category not correctly formatted", c.Scheme)
return fmt.Errorf("scheme attribute of category %v not correctly formatted", c)
}
}
if !isCorrectlyEscaped(c.Label) {
return fmt.Errorf("label attribute %v of category not correctly escaped", c.Label)
return fmt.Errorf("label attribute of category %v not correctly escaped", c)
}
return nil