module Radix.Exception
  ( MalformedTree (..)
  ) where

import           Control.Exception



-- | Exception thrown by functions that need to return a value,
--   but instead find an invariant-breaking empty node.
data MalformedTree = MalformedTree
                       String -- ^ Module name
                       String -- ^ Function name

instance Show MalformedTree where
  showsPrec :: Int -> MalformedTree -> ShowS
showsPrec Int
_ (MalformedTree String
loc String
fun) =
    String -> ShowS
showString String
"radix-tree#"
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
loc ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> ShowS
showChar Char
'.'
      ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
fun ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
": Encountered Nil, tree is malformed"

instance Exception MalformedTree