Added more error handling and necessary functions
This commit is contained in:
11
xhtmlDiv.go
11
xhtmlDiv.go
@@ -2,6 +2,7 @@ package atom
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
@@ -11,12 +12,16 @@ type XHTMLDiv struct {
|
||||
Content string `xml:",innerxml"`
|
||||
}
|
||||
|
||||
// NewXHTMLDiv creates a new XHTMLDiv. It returns a *XHTMLDiv.
|
||||
func NewXHTMLDiv(content string) *XHTMLDiv {
|
||||
// NewXHTMLDiv creates a new XHTMLDiv. It returns a *XHTMLDiv and an error.
|
||||
func NewXHTMLDiv(content string) (*XHTMLDiv, error) {
|
||||
if content == "" {
|
||||
return nil, errors.New("error creating new xhtml div: content string empty")
|
||||
}
|
||||
|
||||
return &XHTMLDiv{
|
||||
XMLNS: "http://www.w3.org/1999/xhtml",
|
||||
Content: content,
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Check checks the XHTMLDiv for incompatibilities with RFC4287. It returns an
|
||||
|
Reference in New Issue
Block a user