module Unison.Runtime.Exception ( RuntimeExn (..), die, dieP, exn, ) where import Control.Exception import Data.String (fromString) import Data.Text import GHC.Stack import Unison.Reference (Reference) import Unison.Runtime.Stack import Unison.Util.Pretty as P data RuntimeExn = PE CallStack (P.Pretty P.ColorText) | BU [(Reference, Int)] Text Val deriving (Int -> RuntimeExn -> ShowS [RuntimeExn] -> ShowS RuntimeExn -> String (Int -> RuntimeExn -> ShowS) -> (RuntimeExn -> String) -> ([RuntimeExn] -> ShowS) -> Show RuntimeExn forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> RuntimeExn -> ShowS showsPrec :: Int -> RuntimeExn -> ShowS $cshow :: RuntimeExn -> String show :: RuntimeExn -> String $cshowList :: [RuntimeExn] -> ShowS showList :: [RuntimeExn] -> ShowS Show) instance Exception RuntimeExn die :: (HasCallStack) => String -> IO a die :: forall a. HasCallStack => String -> IO a die = RuntimeExn -> IO a forall e a. Exception e => e -> IO a throwIO (RuntimeExn -> IO a) -> (String -> RuntimeExn) -> String -> IO a forall b c a. (b -> c) -> (a -> b) -> a -> c . CallStack -> Pretty ColorText -> RuntimeExn PE CallStack HasCallStack => CallStack callStack (Pretty ColorText -> RuntimeExn) -> (String -> Pretty ColorText) -> String -> RuntimeExn forall b c a. (b -> c) -> (a -> b) -> a -> c . ColorText -> Pretty ColorText forall s. (IsString s, ListLike s Char) => s -> Pretty s P.lit (ColorText -> Pretty ColorText) -> (String -> ColorText) -> String -> Pretty ColorText forall b c a. (b -> c) -> (a -> b) -> a -> c . String -> ColorText forall a. IsString a => String -> a fromString {-# INLINE die #-} dieP :: (HasCallStack) => P.Pretty P.ColorText -> IO a dieP :: forall a. HasCallStack => Pretty ColorText -> IO a dieP = RuntimeExn -> IO a forall e a. Exception e => e -> IO a throwIO (RuntimeExn -> IO a) -> (Pretty ColorText -> RuntimeExn) -> Pretty ColorText -> IO a forall b c a. (b -> c) -> (a -> b) -> a -> c . CallStack -> Pretty ColorText -> RuntimeExn PE CallStack HasCallStack => CallStack callStack {-# INLINE dieP #-} exn :: (HasCallStack) => String -> a exn :: forall a. HasCallStack => String -> a exn = RuntimeExn -> a forall a e. Exception e => e -> a throw (RuntimeExn -> a) -> (String -> RuntimeExn) -> String -> a forall b c a. (b -> c) -> (a -> b) -> a -> c . CallStack -> Pretty ColorText -> RuntimeExn PE CallStack HasCallStack => CallStack callStack (Pretty ColorText -> RuntimeExn) -> (String -> Pretty ColorText) -> String -> RuntimeExn forall b c a. (b -> c) -> (a -> b) -> a -> c . ColorText -> Pretty ColorText forall s. (IsString s, ListLike s Char) => s -> Pretty s P.lit (ColorText -> Pretty ColorText) -> (String -> ColorText) -> String -> Pretty ColorText forall b c a. (b -> c) -> (a -> b) -> a -> c . String -> ColorText forall a. IsString a => String -> a fromString {-# INLINE exn #-}