using System; using System.Runtime.Serialization; namespace Umbraco.Web.Install { /// /// Used for steps to be able to return a JSON structure back to the UI. /// /// [Serializable] public class InstallException : Exception { /// /// Gets the view. /// /// /// The view. /// public string View { get; private set; } /// /// Gets the view model. /// /// /// The view model. /// /// /// This object is not included when serializing. /// public object ViewModel { get; private set; } /// /// Initializes a new instance of the class. /// public InstallException() { } /// /// Initializes a new instance of the class. /// /// The message that describes the error. public InstallException(string message) : this(message, "error", null) { } /// /// Initializes a new instance of the class. /// /// The message. /// The view model. public InstallException(string message, object viewModel) : this(message, "error", viewModel) { } /// /// Initializes a new instance of the class. /// /// The message. /// The view. /// The view model. public InstallException(string message, string view, object viewModel) : base(message) { View = view; ViewModel = viewModel; } /// /// Initializes a new instance of the class. /// /// The error message that explains the reason for the exception. /// The exception that is the cause of the current exception, or a null reference ( in Visual Basic) if no inner exception is specified. public InstallException(string message, Exception innerException) : base(message, innerException) { } /// /// Initializes a new instance of the class. /// /// The that holds the serialized object data about the exception being thrown. /// The that contains contextual information about the source or destination. protected InstallException(SerializationInfo info, StreamingContext context) : base(info, context) { View = info.GetString(nameof(View)); } /// /// When overridden in a derived class, sets the with information about the exception. /// /// The that holds the serialized object data about the exception being thrown. /// The that contains contextual information about the source or destination. /// info public override void GetObjectData(SerializationInfo info, StreamingContext context) { if (info == null) { throw new ArgumentNullException(nameof(info)); } info.AddValue(nameof(View), View); base.GetObjectData(info, context); } } }