HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulehslua-core-2.3.2Haskell2010

HsLua.Core.Error

Lua exceptions and exception handling.

  • 2 types
  • 1 class
  • 8 values
classclass Exception e => LuaError e where
#

Any type that you wish to use for error handling in HsLua must be an instance of the LuaError class.

Methods

  • popException :: LuaE e e

    Converts the error at the top of the stack into an exception and pops the error off the stack.

    This function is expected to produce a valid result for any Lua value; neither a Haskell exception nor a Lua error may result when this is called.

  • pushException :: e -> LuaE e ()

    Pushes an exception to the top of the Lua stack. The pushed Lua object is used as an error object, and it is recommended that calling tostring() on the object produces an informative message.

  • luaException :: String -> e

    Creates a new exception with the given message.

Instances1LuaError
typetype Lua a = LuaE Exception a
#

A Lua operation.

This type is suitable for most users. It uses a default exception for error handling. Users who need more control over error handling can use LuaE with a custom error type instead.

valuetry :: Exception e => LuaE e a -> LuaE e (Either e a)
#

Return either the result of a Lua computation or, if an exception was thrown, the error.

Raises an exception that's appropriate when the type of a Lua object at the given index did not match the expected type. The name or description of the expected type is taken as an argument.

Helpers for hslua C wrapper functions.

3 declarations

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.

This helpful as a "last resort" method when implementing popException.

Orphan instances

2 instances