Unify error messages
This commit is contained in:
@@ -2,7 +2,6 @@ package atom
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"html"
|
||||
)
|
||||
@@ -25,16 +24,16 @@ func NewGenerator(text string) *Generator {
|
||||
func (g *Generator) Check() error {
|
||||
if g.URI != "" {
|
||||
if !isValidIRI(g.URI) {
|
||||
return fmt.Errorf("uri attribute %v of generator not correctly formatted", g.URI)
|
||||
return fmt.Errorf("uri attribute of generator %v not correctly formatted", g)
|
||||
}
|
||||
}
|
||||
|
||||
if g.Text == "" {
|
||||
return errors.New("text element of generator empty")
|
||||
return fmt.Errorf("text element of generator %v empty", g)
|
||||
}
|
||||
|
||||
if !isCorrectlyEscaped(g.Text) {
|
||||
return fmt.Errorf("text element %v of generator not correctly escaped", g.Text)
|
||||
return fmt.Errorf("text element of generator %v not correctly escaped", g)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user