using System; namespace LuaInterface { /// /// Exceptions thrown by the Lua runtime because of errors in the script /// public class LuaScriptException : LuaException { private bool isNet; /// /// Returns true if the exception has occured as the result of a .NET exception in user code /// public bool IsNetException { get { return isNet; } set { isNet = value; } } private readonly string source; /// /// The position in the script where the exception was triggered. /// public override string Source { get { return source; } } /// /// Creates a new Lua-only exception. /// /// The message that describes the error. /// The position in the script where the exception was triggered. public LuaScriptException(string message, string source) : base(message) { this.source = source; } /// /// Creates a new .NET wrapping exception. /// /// The .NET exception triggered by user-code. /// The position in the script where the exception was triggered. public LuaScriptException(Exception innerException, string source) : base(innerException.Message, innerException) { this.source = source; this.IsNetException = true; } public override string ToString() { // Prepend the error source return GetType().FullName + ": " + source + Message; } } }