#nullable enable using System; using System.Collections.Generic; namespace IlInterpreter { /// Base exception for all IlInterpreter errors. public class ScriptException : Exception { /// Create the exception with a message. /// The exception message. public ScriptException(string message) : base(message) { } /// Create the exception with a message and an inner cause. /// The exception message. /// The exception that caused this one, if any. public ScriptException(string message, Exception? inner) : base(message, inner) { } } /// Raised when script source fails to compile. public class ScriptCompileException : ScriptException { /// The compiler diagnostics that failed the compilation. public IReadOnlyList Diagnostics { get; } /// Create the exception from the diagnostics that failed the compilation. /// The compiler diagnostics that failed the compilation. public ScriptCompileException(IReadOnlyList diagnostics) : base($"Script compilation failed with {diagnostics.Count} error(s).") { Diagnostics = diagnostics; } } /// Raised when compiled IL fails validation. public class ScriptValidationException : ScriptException { /// Create the exception with a message. /// The exception message. public ScriptValidationException(string message) : base(message) { } } /// Raised during interpreter execution. public class ScriptRuntimeException : ScriptException { /// Create the exception with a message. /// The exception message. public ScriptRuntimeException(string message) : base(message) { } /// Create the exception with a message and an inner cause. /// The exception message. /// The exception that caused this one, if any. public ScriptRuntimeException(string message, Exception? inner) : base(message, inner) { } } }