Cleanup BootFailedException
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Umbraco.Core.Exceptions
|
||||
{
|
||||
/// <summary>
|
||||
/// An exception that is thrown if the Umbraco application cannnot boot.
|
||||
/// An exception that is thrown if the Umbraco application cannot boot.
|
||||
/// </summary>
|
||||
public class BootFailedException : Exception
|
||||
{
|
||||
@@ -29,5 +30,31 @@ namespace Umbraco.Core.Exceptions
|
||||
public BootFailedException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Rethrows a captured <see cref="BootFailedException"/>.
|
||||
/// </summary>
|
||||
/// <remarks>The exception can be null, in which case a default message is used.</remarks>
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user