X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=JVM%2FExceptions.hs;h=2d47af445f0b87ebf502451a7ce60f0f480d37ef;hb=907c7d06647c07e3c757a0b1709f1501f2575826;hp=b90db45a9d35b4c4d052a89f84e71b868c772a2e;hpb=67ab22f9b209bb0dbc0fa69ffa7f59277bf3848c;p=hs-java.git diff --git a/JVM/Exceptions.hs b/JVM/Exceptions.hs index b90db45..2d47af4 100644 --- a/JVM/Exceptions.hs +++ b/JVM/Exceptions.hs @@ -2,6 +2,9 @@ module JVM.Exceptions where import Control.Monad.Exception +import qualified Data.ByteString.Lazy as B + +import JVM.ClassFile data NoItemInPool = forall a. Show a => NoItemInPool a deriving (Typeable) @@ -11,6 +14,36 @@ instance Exception NoItemInPool instance Show NoItemInPool where show (NoItemInPool s) = "Internal error: no such item in pool: <" ++ show s ++ ">" +data UnexpectedEndMethod = UnexpectedEndMethod + deriving (Typeable) + +instance Show UnexpectedEndMethod where + show UnexpectedEndMethod = "endMethod without startMethod!" + +instance Exception UnexpectedEndMethod + +data ENotLoaded = ClassFileNotLoaded FilePath + | JARNotLoaded FilePath String + deriving (Typeable) + +instance Show ENotLoaded where + show (ClassFileNotLoaded p) = "Class file was not loaded: " ++ p + show (JARNotLoaded p c) = "Class was not loaded from JAR: " ++ p ++ ": " ++ c + +instance Exception ENotLoaded + +data ENotFound = ClassNotFound String + | FieldNotFound String B.ByteString + | MethodNotFound String B.ByteString + deriving (Typeable) + +instance Show ENotFound where + show (ClassNotFound p) = "No such class in ClassPath: " ++ p + show (FieldNotFound c f) = "No such field in class " ++ c ++ ": " ++ toString f + show (MethodNotFound c m) = "No such method in class " ++ c ++ ": " ++ toString m + +instance Exception ENotFound + force :: String -> EM AnyException a -> a force s x = case tryEM x of