Unify error messages
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package atom
|
||||
|
||||
import "errors"
|
||||
import "fmt"
|
||||
|
||||
type PlainText struct {
|
||||
*CommonAttributes
|
||||
@@ -15,15 +15,15 @@ func (p *PlainText) isText() bool { return true }
|
||||
// error.
|
||||
func (p *PlainText) Check() error {
|
||||
if p.Type != "" && p.Type != "text" && p.Type != "html" {
|
||||
return errors.New("type attribute of plain text must be text or html if not omitted")
|
||||
return fmt.Errorf("type attribute of plain text %v must be text or html if not omitted", p)
|
||||
}
|
||||
|
||||
if p.Type == "html" && !isCorrectlyEscaped(p.Text) {
|
||||
return errors.New("text element of plain text not correctly escaped")
|
||||
return fmt.Errorf("text element of plain text %v not correctly escaped", p)
|
||||
}
|
||||
|
||||
if p.Text == "" {
|
||||
return errors.New("text element of plain text empty")
|
||||
return fmt.Errorf("text element of plain text %v empty", p)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user