Added more error handling and necessary functions

This commit is contained in:
2024-10-19 12:28:09 +02:00
parent d4e7bce5e2
commit f4dfd6d060
22 changed files with 317 additions and 122 deletions

View File

@@ -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