Skip to content

Commit

Permalink
Remove panics
Browse files Browse the repository at this point in the history
  • Loading branch information
bserdar committed Oct 30, 2023
1 parent 2a4c03a commit afea191
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 28 deletions.
1 change: 1 addition & 0 deletions basicdocumenttype.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type BasicDocumentType struct {
defn string
}

func (dt *BasicDocumentType) GetNodeType() NodeType { return DOCUMENT_TYPE_NODE }
func (dt *BasicDocumentType) GetName() string { return dt.name }
func (dt *BasicDocumentType) GetPublicID() string { return dt.publicID }
func (dt *BasicDocumentType) GetSystemID() string { return dt.systemID }
Expand Down
37 changes: 9 additions & 28 deletions basicnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,14 @@ func (node *basicNode) GetRootNode() Node {
return getRootNode(node)
}

func (node *basicNode) GetNodeName() string {
panic("basicNode.GetNodeName should not have been called")
}
func (node *basicNode) GetNodeType() NodeType { return 255 }
func (node *basicNode) GetNodeName() string { return "" }

func (node *basicNode) GetNodeType() NodeType {
panic("basicNode.GetNodeType should not have been called")
}
func (node *basicNode) IsEqualNode(Node) bool { return false }

func (node *basicNode) IsEqualNode(Node) bool {
panic("basicNode.IsEqualNode should not have been called")
}

func (node *basicNode) CloneNode(bool) Node {
panic("basicNode.CloneNode should not have been called")
}
func (node *basicNode) CloneNode(bool) Node { return nil }

func (node *basicNode) cloneNode(_ Document, _ bool) Node {
panic("basicNode.cloneNode should not have been called")
}
func (node *basicNode) cloneNode(_ Document, _ bool) Node { return nil }

// Returns a boolean value indicating whether or not the element has
// any child nodes.
Expand Down Expand Up @@ -133,23 +122,15 @@ func (node *basicNode) GetChildNodes() NodeList {
return newBasicNodeList(node)
}

func (node *basicNode) IsSameNode(Node) bool {
panic(ErrHierarchyRequest("IsSameNode", "Wrong node type"))
}
func (node *basicNode) IsSameNode(Node) bool { return false }

func (node *basicNode) InsertBefore(newNode, referenceNode Node) Node {
panic(ErrHierarchyRequest("InsertBefore", "Wrong node type"))
}
func (node *basicNode) InsertBefore(newNode, referenceNode Node) Node { return nil }

// Append newNode as a child of node
func (node *basicNode) AppendChild(newNode Node) Node {
panic(ErrHierarchyRequest("AppendChild", "Wrong node type"))
}
func (node *basicNode) AppendChild(newNode Node) Node { return nil }

// Remove child from node
func (node *basicNode) RemoveChild(child Node) {
panic(ErrHierarchyRequest("RemoveChild", "Wrong node type"))
}
func (node *basicNode) RemoveChild(child Node) {}

// Returns a string containing the prefix for a given namespace
// URI, if present, and "" if not. When multiple prefixes are
Expand Down

0 comments on commit afea191

Please sign in to comment.