org.luaj.vm2
Class LuaError

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by org.luaj.vm2.LuaError
All Implemented Interfaces:
java.io.Serializable

public class LuaError
extends java.lang.RuntimeException

RuntimeException that is thrown and caught in response to a lua error.

LuaError is used wherever a lua call to error() would be used within a script.

Since it is an unchecked exception inheriting from RuntimeException, Java method signatures do notdeclare this exception, althoug it can be thrown on almost any luaj Java operation. This is analagous to the fact that any lua script can throw a lua error at any time.

The LuaError may be constructed with a message object, in which case the message is the string representation of that object. getMessageObject will get the object supplied at construct time, or a LuaString containing the message of an object was not supplied.

See Also:
Serialized Form

Field Summary
protected  java.lang.Throwable cause
           
protected  java.lang.String fileline
           
protected  int level
           
protected  java.lang.String traceback
           
 
Constructor Summary
LuaError(LuaValue message_object)
          Construct a LuaError with a LuaValue as the message object, and level to draw line number information from.
LuaError(java.lang.String message)
          Construct a LuaError with a specific message.
LuaError(java.lang.String message, int level)
          Construct a LuaError with a message, and level to draw line number information from.
LuaError(java.lang.Throwable cause)
          Construct LuaError when a program exception occurs.
 
Method Summary
 java.lang.Throwable getCause()
          Get the cause, if any.
 java.lang.String getMessage()
          Get the string message if it was supplied, or a string representation of the message object if that was supplied.
 LuaValue getMessageObject()
          Get the LuaValue that was provided in the constructor, or a LuaString containing the message if it was a string error argument.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

level

protected int level

fileline

protected java.lang.String fileline

traceback

protected java.lang.String traceback

cause

protected java.lang.Throwable cause
Constructor Detail

LuaError

public LuaError(java.lang.Throwable cause)
Construct LuaError when a program exception occurs.

All errors generated from lua code should throw LuaError(String) instead.

Parameters:
cause - the Throwable that caused the error, if known.

LuaError

public LuaError(java.lang.String message)
Construct a LuaError with a specific message.

Parameters:
message - message to supply

LuaError

public LuaError(java.lang.String message,
                int level)
Construct a LuaError with a message, and level to draw line number information from.

Parameters:
message - message to supply
level - where to supply line info from in call stack

LuaError

public LuaError(LuaValue message_object)
Construct a LuaError with a LuaValue as the message object, and level to draw line number information from.

Parameters:
message_object - message string or object to supply
Method Detail

getMessage

public java.lang.String getMessage()
Get the string message if it was supplied, or a string representation of the message object if that was supplied.

Overrides:
getMessage in class java.lang.Throwable

getMessageObject

public LuaValue getMessageObject()
Get the LuaValue that was provided in the constructor, or a LuaString containing the message if it was a string error argument.

Returns:
LuaValue which was used in the constructor, or a LuaString containing the message.

getCause

public java.lang.Throwable getCause()
Get the cause, if any.

Overrides:
getCause in class java.lang.Throwable


Copyright © 2007-2015 Luaj.org. All Rights Reserved.