/* Copyright (C) 2014-2019 de4dot@gmail.com This file is part of dnSpy dnSpy is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. dnSpy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with dnSpy. If not, see . */ using System; namespace dnSpy.Debugger.DotNet.Interpreter { #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member public enum InterpreterExceptionKind { TooManyInstructions, InvalidMethodBody, InstructionNotSupported, } #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member /// /// Interpreter exception /// [Serializable] public abstract class InterpreterException : Exception { /// /// Gets the exception kind /// public abstract InterpreterExceptionKind Kind { get; } /// /// Constructor /// /// Message protected InterpreterException(string message) : base(message) { } /// /// Constructor /// /// Message /// Inner exception protected InterpreterException(string message, Exception innerException) : base(message, innerException) { } } /// /// Thrown when too many instructions have been interpreted /// [Serializable] public class TooManyInstructionsInterpreterException : InterpreterException { /// /// Returns /// public override InterpreterExceptionKind Kind => InterpreterExceptionKind.TooManyInstructions; /// /// Constructor /// public TooManyInstructionsInterpreterException() : base("Too many instructions have been executed") { } } /// /// Invalid method body, eg. last instruction isn't an unconditional branch instruction (eg. ret/throw) /// [Serializable] public class InvalidMethodBodyInterpreterException : InterpreterException { /// /// Returns /// public override InterpreterExceptionKind Kind => InterpreterExceptionKind.InvalidMethodBody; const string MESSAGE = "Invalid method body"; /// /// Constructor /// public InvalidMethodBodyInterpreterException() : base(MESSAGE) { } /// /// Constructor /// /// Inner exception public InvalidMethodBodyInterpreterException(Exception innerException) : base(MESSAGE, innerException) { } } /// /// Unsupported IL instruction /// [Serializable] public class InstructionNotSupportedInterpreterException : InterpreterException { /// /// Returns /// public override InterpreterExceptionKind Kind => InterpreterExceptionKind.InstructionNotSupported; /// /// Constructor /// /// Message public InstructionNotSupportedInterpreterException(string message) : base(message) { } } }