Copyright | © 2017-2019 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
- throwTopMessage :: Lua a
- try :: Lua a -> Lua (Either Exception a)
- newtype Failable a = Failable CInt
- fromFailable :: (CInt -> a) -> Failable a -> Lua a
- throwOnError :: Failable () -> Lua ()
- boolFromFailable :: Failable LuaBool -> Lua Bool
- hsluaErrorRegistryField :: String
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
throwTopMessage :: Lua a Source #
Convert the object at the top of the stack into a string and throw it as
an
.Exception
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.
CInt value or an error, using the convention that value below zero indicate an error. Values greater than zero are used verbatim. The phantom type is used for additional type safety and gives the type into which the wrapped CInt should be converted.
fromFailable :: (CInt -> a) -> Failable a -> Lua a Source #
Convert from Failable to target type, throwing an error if the value indicates a failure.
throwOnError :: Failable () -> Lua () Source #
Throw a Haskell exception if the computation signaled a failure.
boolFromFailable :: Failable LuaBool -> Lua Bool Source #
Convert lua boolean to Haskell Bool, throwing an exception if the return value indicates that an error had happened.
Signaling errors to Lua
hsluaErrorRegistryField :: String Source #
Registry field under which the special HsLua error indicator is stored.