module Neovim.Exceptions
( NeovimException(..)
) where
import Control.Exception (Exception)
import Data.MessagePack (Object (..))
import Data.String (IsString (..))
import Data.Typeable (Typeable)
import Text.PrettyPrint.ANSI.Leijen (Doc, Pretty (..))
data NeovimException
= ErrorMessage Doc
| ErrorResult Object
deriving (Typeable, Show)
instance Exception NeovimException
instance IsString NeovimException where
fromString = ErrorMessage . fromString
instance Pretty NeovimException where
pretty = \case
ErrorMessage s -> s
ErrorResult e -> pretty $ show e