Cleanup BootFailedException

This commit is contained in:
Stephan
2018-10-25 15:07:04 +02:00
parent d3a894b7a3
commit d1e377bc38
3 changed files with 47 additions and 18 deletions

View File

@@ -2,6 +2,7 @@
using System.Web;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Exceptions;
namespace Umbraco.Web.Composing
{
@@ -21,16 +22,28 @@ namespace Umbraco.Web.Composing
{
// using the service locator here - no other way, really
Module = Current.Container.GetInstance<TModule>();
Module.Init(context);
}
catch
{
var runtimeState = Current.Container.GetInstance<IRuntimeState>();
if (runtimeState.BootFailedException != null)
// if GetInstance fails, it may be because of a boot error, in
// which case that is the error we actually want to report
IRuntimeState runtimeState = null;
try
{
throw new Exception("Failed to boot", runtimeState.BootFailedException);
runtimeState = Current.Container.GetInstance<IRuntimeState>();
}
catch { /* don't make it worse */ }
if (runtimeState?.BootFailedException != null)
BootFailedException.Rethrow(runtimeState.BootFailedException);
// else... throw what we have
throw;
}
// initialize
Module.Init(context);
}
/// <inheritdoc />