Module jls.lang.Exception

Represents an abnormal event.

An exception instance captures the error message and the associated stack.

Class Exception

Exception:new ([message[, cause[, stack[, name]]]]) Creates a new Exception.
exception:getMessage () Returns the message of this exception.
exception:getCause () Returns the cause of this exception.
exception:getStackTrace () Returns the stack of this exception.
Exception.getMessage (e) Returns the message of the specified value if it is an exception or the specified value itself.
Exception.pcall (fn[, ...]) Calls the specified function with the given arguments in protected mode.
Exception.try (fn[, ...]) Calls the specified function with the given arguments in protected mode.


Class Exception

The Exception class.
Exception:new ([message[, cause[, stack[, name]]]])
Creates a new Exception. The stack is removed from the message. The stack trace and the name will be generated automatically.

Parameters:

  • message The exception message (optional)
  • cause The exception cause (optional)
  • stack string The exception stack (optional)
  • name string The exception name (optional)
exception:getMessage ()
Returns the message of this exception. The message is the error object passed to the error function.

Returns:

    The message of this exception possibly nil
exception:getCause ()
Returns the cause of this exception.

Returns:

    The cause of this exception if any or nil
exception:getStackTrace ()
Returns the stack of this exception. A traceback of the call stack when this exception was created and thrown

Returns:

    string The stack of this exception
Exception.getMessage (e)
Returns the message of the specified value if it is an exception or the specified value itself.

Parameters:

  • e The exception or error message

Returns:

    The message of the exception possibly nil
Exception.pcall (fn[, ...])
Calls the specified function with the given arguments in protected mode.

Parameters:

  • fn function The function to call in protected mode
  • ... The arguments to call the function with (optional)

Returns:

  1. boolean true if the call succeeds without errors
  2. The returned values of the call or the Exception in case of error
Exception.try (fn[, ...])
Calls the specified function with the given arguments in protected mode.

Parameters:

  • fn function The function to call in protected mode
  • ... The arguments to call the function with (optional)

Returns:

    The returned values of the call or nil plus the Exception in case of error
generated by LDoc 1.4.6