Skip to content

Commit

Permalink
refactor(Trie): improve panic message
Browse files Browse the repository at this point in the history
  • Loading branch information
Khalid-Nowaf committed Jun 29, 2024
1 parent 3e20f5c commit b4b094f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/trie/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ func (t *BinaryTrie[T]) AddSibling(sibling *BinaryTrie[T]) *BinaryTrie[T] {
//
// node.GetChildAt(trie.Zero)
func (t *BinaryTrie[T]) GetChildAt(at ChildPos) *BinaryTrie[T] {
// TODO: user can get nil

if t == nil {
panic("Unexpected nil value")
panic("[BUG] GetChildAt: struct must not be nil nil")
}

return t.Children[at]
Expand All @@ -100,7 +100,7 @@ func (t *BinaryTrie[T]) Detach() {
if !t.isRoot() {
t.Parent.Children[t.GetPos()] = nil
} else {
panic("You can not remove the root")
panic("[BUG] Detach: You can not Detach the root")
}
}

Expand All @@ -117,7 +117,7 @@ func (t *BinaryTrie[T]) Detach() {
func (t *BinaryTrie[T]) DetachBranch(limit int) *BinaryTrie[T] {
// if it has children
if t.isRoot() {
panic("You can not detach Root")
panic("[Bug] DetachBranch: You can not detach Root")
}
nearestBranchedNode := t
t.ForEachStepUp(func(next *BinaryTrie[T]) {
Expand Down

0 comments on commit b4b094f

Please sign in to comment.