using System; using System.Text; namespace Umbraco.Core.Exceptions { /// /// An exception that is thrown if the Umbraco application cannot boot. /// public class BootFailedException : Exception { /// /// Defines the default boot failed exception message. /// public const string DefaultMessage = "Boot failed: Umbraco cannot run. See Umbraco's log file for more details."; /// /// Initializes a new instance of the class with a specified error message. /// /// The message that describes the error. public BootFailedException(string message) : base(message) { } /// /// Initializes a new instance of the class with a specified error message /// and a reference to the inner exception which is the cause of this exception. /// /// The message that describes the error. /// The inner exception, or null. public BootFailedException(string message, Exception inner) : base(message, inner) { } /// /// Rethrows a captured . /// /// The exception can be null, in which case a default message is used. public static void Rethrow(BootFailedException bootFailedException) { if (bootFailedException == null) throw new BootFailedException(DefaultMessage); // see https://stackoverflow.com/questions/57383 // would that be the correct way to do it? //ExceptionDispatchInfo.Capture(bootFailedException).Throw(); Exception e = bootFailedException; var m = new StringBuilder(); m.Append(DefaultMessage); while (e != null) { m.Append($"\n\n-> {e.GetType().FullName}: {e.Message}"); if (string.IsNullOrWhiteSpace(e.StackTrace) == false) m.Append($"\n{e.StackTrace}"); e = e.InnerException; } throw new BootFailedException(m.ToString()); } } }