Log full exceptions
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using Hcs.WebApp.Data.Hcs;
|
||||
using Hcs.WebApp.Services;
|
||||
using Hcs.WebApp.Utils;
|
||||
|
||||
namespace Hcs.WebApp.BackgroundServices.CampaignManagers
|
||||
{
|
||||
@ -26,7 +27,7 @@ namespace Hcs.WebApp.BackgroundServices.CampaignManagers
|
||||
|
||||
public async Task EndWithFailAsync(Exception e)
|
||||
{
|
||||
await HeadquartersService.SetCampaignEndedWithFailAsync(campaign.Id, e.Message);
|
||||
await HeadquartersService.SetCampaignEndedWithFailAsync(campaign.Id, e.CombineMessages());
|
||||
|
||||
State = IManager.ManagerState.Ended;
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ using Hcs.Broker.MessageCapturer;
|
||||
using Hcs.WebApp.BackgroundServices.OperationExecutors;
|
||||
using Hcs.WebApp.Config;
|
||||
using Hcs.WebApp.Services;
|
||||
using Hcs.WebApp.Utils;
|
||||
using System.Transactions;
|
||||
|
||||
namespace Hcs.WebApp.BackgroundServices
|
||||
@ -45,7 +46,7 @@ namespace Hcs.WebApp.BackgroundServices
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await headquartersService.SetOperationEndedWithFailAsync(operation.Id, e.Message);
|
||||
await headquartersService.SetOperationEndedWithFailAsync(operation.Id, e.CombineMessages());
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(messageGuid))
|
||||
|
||||
@ -5,6 +5,7 @@ using Hcs.WebApp.BackgroundServices.ResultGetters;
|
||||
using Hcs.WebApp.Config;
|
||||
using Hcs.WebApp.Data.Hcs;
|
||||
using Hcs.WebApp.Services;
|
||||
using Hcs.WebApp.Utils;
|
||||
|
||||
namespace Hcs.WebApp.BackgroundServices
|
||||
{
|
||||
@ -80,7 +81,7 @@ namespace Hcs.WebApp.BackgroundServices
|
||||
catch (Exception e)
|
||||
{
|
||||
var headquartersService = scope.ServiceProvider.GetRequiredService<HeadquartersService>();
|
||||
await headquartersService.SetOperationEndedWithFailAsync(entry.operation.Id, e.Message);
|
||||
await headquartersService.SetOperationEndedWithFailAsync(entry.operation.Id, e.CombineMessages());
|
||||
|
||||
entry.state.done = true;
|
||||
}
|
||||
|
||||
20
Hcs.WebApp/Utils/ExceptionExtensions.cs
Normal file
20
Hcs.WebApp/Utils/ExceptionExtensions.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.Text;
|
||||
|
||||
namespace Hcs.WebApp.Utils
|
||||
{
|
||||
public static class ExceptionExtensions
|
||||
{
|
||||
public static string CombineMessages(this Exception e)
|
||||
{
|
||||
var stringBuilder = new StringBuilder();
|
||||
var currentException = e;
|
||||
while (currentException != null)
|
||||
{
|
||||
stringBuilder.AppendLine(currentException.Message);
|
||||
|
||||
currentException = currentException.InnerException;
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user