Skip to content

Commit

Permalink
enabled Directive.Resume to log the full Exception (#6071)
Browse files Browse the repository at this point in the history
Modified the default `SupervisorStrategy` to record the full `Exception` when a `Warning` is issued when a `Directive.Resume` is returned by the `Decider` when handling child actor failures. The only material impact of this is improved visibility into the stack trace and error details.
  • Loading branch information
Aaronontheweb committed Aug 23, 2022
1 parent c948581 commit b956e4b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/core/Akka/Actor/SupervisorStrategy.cs
Expand Up @@ -142,17 +142,16 @@ protected virtual void LogFailure(IActorContext context, IActorRef child, Except
{
if (LoggingEnabled)
{
var actorInitializationException = cause as ActorInitializationException;
string message;
if (actorInitializationException != null && actorInitializationException.InnerException != null)
if (cause is ActorInitializationException actorInitializationException && actorInitializationException.InnerException != null)
message = actorInitializationException.InnerException.Message;
else
message = cause.Message;

switch (directive)
{
case Directive.Resume:
Publish(context, new Warning(child.Path.ToString(), GetType(), message));
Publish(context, new Warning(cause, child.Path.ToString(), GetType(), message));
break;
case Directive.Escalate:
//Don't log here
Expand All @@ -171,7 +170,7 @@ protected virtual void LogFailure(IActorContext context, IActorRef child, Except
/// </summary>
protected bool LoggingEnabled { get; set; }

private void Publish(IActorContext context, LogEvent logEvent)
private static void Publish(IActorContext context, LogEvent logEvent)
{
try
{
Expand Down

0 comments on commit b956e4b

Please sign in to comment.