JVM assembler/disassembler tested to work on Hello.java.
[hs-java.git] / JVM / Exceptions.hs
1 {-# LANGUAGE DeriveDataTypeable, ExistentialQuantification #-}
2 module JVM.Exceptions where
3
4 import Control.Monad.Exception
5 import qualified Data.ByteString.Lazy as B
6
7 import JVM.Types
8
9 data NoItemInPool = forall a. Show a => NoItemInPool a
10   deriving (Typeable)
11
12 instance Exception NoItemInPool
13
14 instance Show NoItemInPool where
15   show (NoItemInPool s) = "Internal error: no such item in pool: <" ++ show s ++ ">"
16
17 force :: String -> EM AnyException a -> a
18 force s x =
19   case tryEM x of
20     Right result -> result
21     Left  exc    -> error $ "Exception at " ++ s ++ ": " ++ show exc