Unify error messages
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user