Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions src/contrib/testkits/Akka.TestKit.Xunit/Internals/Loggers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,13 @@ private void HandleLogEvent(LogEvent e)
_output.WriteLine(e.ToString());
}
catch (FormatException ex)
when (e.Message is LogMessage msg)
{
if (e.Message is LogMessage msg)
{
var message =
$"Received a malformed formatted message. Log level: [{e.LogLevel()}], Template: [{msg.Format}], args: [{string.Join(",", msg.Unformatted())}]";
if (e.Cause != null)
throw new AggregateException(message, ex, e.Cause);
throw new FormatException(message, ex);
}

throw;
var message =
$"Received a malformed formatted message. Log level: [{e.LogLevel()}], Template: [{msg.Format}], args: [{string.Join(",", msg.Unformatted())}]";
if (e.Cause != null)
throw new AggregateException(message, ex, e.Cause);
throw new FormatException(message, ex);
}
catch (InvalidOperationException ie)
{
Expand Down
16 changes: 6 additions & 10 deletions src/contrib/testkits/Akka.TestKit.Xunit2/Internals/Loggers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,13 @@ private void HandleLogEvent(LogEvent e)
_output.WriteLine(e.ToString());
}
catch (FormatException ex)
when (e.Message is LogMessage msg)
{
if (e.Message is LogMessage msg)
{
var message =
$"Received a malformed formatted message. Log level: [{e.LogLevel()}], Template: [{msg.Format}], args: [{string.Join(",", msg.Unformatted())}]";
if (e.Cause != null)
throw new AggregateException(message, ex, e.Cause);
throw new FormatException(message, ex);
}

throw;
var message =
$"Received a malformed formatted message. Log level: [{e.LogLevel()}], Template: [{msg.Format}], args: [{string.Join(",", msg.Unformatted())}]";
if (e.Cause != null)
throw new AggregateException(message, ex, e.Cause);
throw new FormatException(message, ex);
}
catch (InvalidOperationException ie)
{
Expand Down
19 changes: 9 additions & 10 deletions src/core/Akka.Discovery/Discovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,16 @@ private ServiceDiscovery CreateServiceDiscovery(string method)
return Create(className);
}
catch (Exception ex)
when (ex is TypeLoadException or MissingMethodException)
{
if (ex is TypeLoadException or MissingMethodException)
throw new ArgumentException(
message: $"Illegal akka.discovery.{method}.class value or incompatible class!\n" +
"The implementation class MUST extend Akka.Discovery.ServiceDiscovery with:\n" +
" * parameterless constructor, " +
$" * constructor with a single {nameof(ExtendedActorSystem)} parameter, or\n" +
$" * constructor with {nameof(ExtendedActorSystem)} and {nameof(Configuration.Config)} parameters.",
paramName: nameof(method),
innerException: ex);
throw;
throw new ArgumentException(
message: $"Illegal akka.discovery.{method}.class value or incompatible class!\n" +
"The implementation class MUST extend Akka.Discovery.ServiceDiscovery with:\n" +
" * parameterless constructor, " +
$" * constructor with a single {nameof(ExtendedActorSystem)} parameter, or\n" +
$" * constructor with {nameof(ExtendedActorSystem)} and {nameof(Configuration.Config)} parameters.",
paramName: nameof(method),
innerException: ex);
}

ServiceDiscovery Create(string typeName)
Expand Down
8 changes: 4 additions & 4 deletions src/core/Akka.Persistence/Journal/ReplayFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,18 +233,18 @@ protected override bool Receive(object message)
throw new ArgumentException("Mode must not be Disabled");
}
}

node = next;
}

_buffer.AddLast(value);
}

}
catch (IllegalStateException ex)
when (Mode == ReplayFilterMode.Fail)
{
if (Mode == ReplayFilterMode.Fail)
Fail(ex);
else
throw;
Fail(ex);
}
}
else if (message is RecoverySuccess or ReplayMessagesFailure)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,11 @@ public Property HeliosTransport_Should_Resolve_DNS(EndPoint inbound, EndPoint ou
useIpv6Dns: dnsIpv6,
enforceIpFamily: enforceIpFamily);
}
catch
catch when (enforceIpFamily && IsExpectedFailure(inbound, outbound, dnsIpv6))
{
//if ip family is enforced, there are some special cases when it is normal to unable
//to create actor system
if (enforceIpFamily && IsExpectedFailure(inbound, outbound, dnsIpv6))
return true.ToProperty();
throw;
return true.ToProperty();
}

var outboundReceivedAck = true;
Expand Down Expand Up @@ -246,14 +244,13 @@ public Property HeliosTransport_Should_Resolve_DNS_with_PublicHostname(IPEndPoin
dnsUseIpv6,
enforceIpFamily);
}
catch
catch when (enforceIpFamily && IsExpectedFailure(inbound, outbound, dnsUseIpv6))
{
//if ip family is enforced, there are some special cases when it is normal to unable
//to create actor system
if (enforceIpFamily && IsExpectedFailure(inbound, outbound, dnsUseIpv6))
return true.ToProperty();
throw;
return true.ToProperty();
}

var outboundReceivedAck = true;
var inboundReceivedAck = true;
_outbound.ActorSelection(_inboundAck).Tell("ping", _outboundProbe.Ref);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,10 @@ public static SslSettings CreateOrDefault(Config config, SslSettings? @default =
{
return Create(config);
}
catch(Exception)
catch (Exception)
when (@default != null)
{
if (@default != null)
return @default;
throw;
return @default;
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/core/Akka.Streams/Implementation/ActorPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,8 @@ private void ReportSubscribeFailure(ISubscriber<TOut> subscriber)
}
}
catch (Exception exception)
when (exception is ISpecViolation)
{
if (!(exception is ISpecViolation))
throw;
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions src/core/Akka.Streams/Implementation/CompletedPublishers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ public void Subscribe(ISubscriber<T> subscriber)
ReactiveStreamsCompliance.TryOnComplete(subscriber);
}
catch (Exception e)
when (e is ISpecViolation)
{
if (!(e is ISpecViolation))
throw;
}
}

Expand Down Expand Up @@ -91,9 +90,8 @@ public void Subscribe(ISubscriber<T> subscriber)
ReactiveStreamsCompliance.TryOnError(subscriber, Cause);
}
catch (Exception e)
when (e is ISpecViolation)
{
if (!(e is ISpecViolation))
throw;
}
}

Expand Down Expand Up @@ -270,9 +268,8 @@ public void Subscribe(ISubscriber<T> subscriber)
ReactiveStreamsCompliance.RejectAdditionalSubscriber(subscriber, "Publisher");
}
catch (Exception e)
when (e is ISpecViolation)
{
if (!(e is ISpecViolation))
throw;
}
}

Expand Down
10 changes: 3 additions & 7 deletions src/core/Akka.Streams/Implementation/SubscriberManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,10 @@ private long DispatchFromBufferAndReturnRemainingRequested(long requested, ISubs
goOn = true;
}
catch (Exception e)
when (e is ISpecViolation)
{
if (e is ISpecViolation)
{
UnregisterSubscriptionInternal(subscription);
goOn = false;
}
else
throw;
UnregisterSubscriptionInternal(subscription);
goOn = false;
}

if (!goOn)
Expand Down
8 changes: 3 additions & 5 deletions src/core/Akka.TestKit/Internal/InternalTestActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,10 @@ protected override void OnReceive(object message)
System.Diagnostics.Debug.WriteLine("TestActor received " + message);
}
catch (FormatException)
when (message is LogEvent { Message: LogMessage msg })
{
if (message is LogEvent { Message: LogMessage msg })
System.Diagnostics.Debug.WriteLine(
$"TestActor received a malformed formatted message. Template:[{msg.Format}], args:[{string.Join(",", msg.Unformatted())}]");
else
throw;
System.Diagnostics.Debug.WriteLine(
$"TestActor received a malformed formatted message. Template:[{msg.Format}], args:[{string.Join(",", msg.Unformatted())}]");
}

switch (message)
Expand Down
5 changes: 2 additions & 3 deletions src/core/Akka/Dispatch/Mailboxes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,9 @@ MailboxType VerifyRequirements(MailboxType mailboxType)
return VerifyRequirements(LookupByQueueType(actorRequirement.Value));
}
catch (Exception)
when (hasMailboxRequirement)
{
if (hasMailboxRequirement)
return VerifyRequirements(LookupByQueueType(mailboxRequirement));
throw;
return VerifyRequirements(LookupByQueueType(mailboxRequirement));
}
}
if (hasMailboxRequirement)
Expand Down
Loading