Added more error handling and necessary functions
This commit is contained in:
14
plainText.go
14
plainText.go
@@ -1,6 +1,9 @@
|
||||
package atom
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type PlainText struct {
|
||||
*CommonAttributes
|
||||
@@ -11,6 +14,15 @@ type PlainText struct {
|
||||
// isText checks whether the PlainText is a Text. It returns a bool.
|
||||
func (p *PlainText) isText() bool { return true }
|
||||
|
||||
// newPlainText creates a new PlainText. It returns a *PlainText and an error.
|
||||
func newPlainText(textType, content string) (*PlainText, error) {
|
||||
if content == "" {
|
||||
return nil, errors.New("error creating new plain text: content string empty")
|
||||
}
|
||||
|
||||
return &PlainText{Type: textType, Text: content}, nil
|
||||
}
|
||||
|
||||
// Check checks the PlainText for incompatibilities with RFC4287. It returns an
|
||||
// error.
|
||||
func (p *PlainText) Check() error {
|
||||
|
Reference in New Issue
Block a user