Copyright | © 2017-2020 Albert Krewinkel |
---|---|
License | MIT |
Maintainer | Albert Krewinkel <tarleb+hslua@zeitkraut.de> |
Stability | beta |
Portability | DeriveDataTypeable |
Safe Haskell | None |
Language | Haskell2010 |
Lua exceptions and exception handling.
Synopsis
- newtype Exception = Exception {}
- catchException :: Lua a -> (Exception -> Lua a) -> Lua a
- throwException :: String -> Lua a
- withExceptionMessage :: (String -> String) -> Lua a -> Lua a
- throwErrorAsException :: Lua a
- throwTopMessage :: Lua a
- throwTopMessageWithState :: State -> IO a
- errorMessage :: State -> IO ByteString
- try :: Lua a -> Lua (Either Exception a)
- throwMessage :: String -> Lua a
- liftLuaThrow :: (State -> Ptr StatusCode -> IO a) -> Lua a
Documentation
Exceptions raised by Lua-related operations.
Instances
Eq Exception Source # | |
Show Exception Source # | |
Exception Exception Source # | |
Defined in Foreign.Lua.Core.Error toException :: Exception -> SomeException # fromException :: SomeException -> Maybe Exception # displayException :: Exception -> String # |
withExceptionMessage :: (String -> String) -> Lua a -> Lua a Source #
Catch Lua
, alter the message and rethrow.Exception
throwErrorAsException :: Lua a Source #
Convert a Lua error into a Haskell exception. The error message is expected to be at the top of the stack.
throwTopMessage :: Lua a Source #
Alias for throwErrorAsException
; will be deprecated in the next
mayor release.
throwTopMessageWithState :: State -> IO a Source #
Convert the object at the top of the stack into a string and throw
it as a HsLua
.Exception
This function serves as the default to convert Lua errors to Haskell exceptions.
errorMessage :: State -> IO ByteString Source #
Retrieve and pop the top object as an error message. This is very similar to tostring', but ensures that we don't recurse if getting the message failed.
try :: Lua a -> Lua (Either Exception a) Source #
Return either the result of a Lua computation or, if an exception was thrown, the error.
Helpers for hslua C wrapper functions.
throwMessage :: String -> Lua a Source #
Helper function which uses proper error-handling to throw an exception with the given message.
liftLuaThrow :: (State -> Ptr StatusCode -> IO a) -> Lua a Source #
Takes a failable HsLua function and transforms it into a
monadic Lua
operation. Throws an exception if an error
occured.