Add descriptive message for MessagingExceptions.
We can print this message in EventuallyConsistentMapImpl rather than printing a stack trace which doesn't add any value because the exception always comes from the same place. Change-Id: Ia233e7ae8605b2b59ffd4ef834209fdaa86e9376
Showing
3 changed files
with
16 additions
and
5 deletions
... | @@ -42,17 +42,26 @@ public class MessagingException extends IOException { | ... | @@ -42,17 +42,26 @@ public class MessagingException extends IOException { |
42 | * Exception indicating no remote registered remote handler. | 42 | * Exception indicating no remote registered remote handler. |
43 | */ | 43 | */ |
44 | public static class NoRemoteHandler extends MessagingException { | 44 | public static class NoRemoteHandler extends MessagingException { |
45 | + public NoRemoteHandler() { | ||
46 | + super("No remote message handler registered for this message"); | ||
47 | + } | ||
45 | } | 48 | } |
46 | 49 | ||
47 | /** | 50 | /** |
48 | * Exception indicating handler failure. | 51 | * Exception indicating handler failure. |
49 | */ | 52 | */ |
50 | public static class RemoteHandlerFailure extends MessagingException { | 53 | public static class RemoteHandlerFailure extends MessagingException { |
54 | + public RemoteHandlerFailure() { | ||
55 | + super("Remote handler failed to handle message"); | ||
56 | + } | ||
51 | } | 57 | } |
52 | 58 | ||
53 | /** | 59 | /** |
54 | - * Exception indicating failure due to invalid message strucuture such as an incorrect preamble. | 60 | + * Exception indicating failure due to invalid message structure such as an incorrect preamble. |
55 | */ | 61 | */ |
56 | - public static class ProcotolException extends MessagingException { | 62 | + public static class ProtocolException extends MessagingException { |
63 | + public ProtocolException() { | ||
64 | + super("Failed to process message due to invalid message structure"); | ||
65 | + } | ||
57 | } | 66 | } |
58 | } | 67 | } | ... | ... |
... | @@ -545,7 +545,7 @@ public class NettyMessagingManager implements MessagingService { | ... | @@ -545,7 +545,7 @@ public class NettyMessagingManager implements MessagingService { |
545 | } else if (message.status() == Status.ERROR_HANDLER_EXCEPTION) { | 545 | } else if (message.status() == Status.ERROR_HANDLER_EXCEPTION) { |
546 | callback.completeExceptionally(new MessagingException.RemoteHandlerFailure()); | 546 | callback.completeExceptionally(new MessagingException.RemoteHandlerFailure()); |
547 | } else if (message.status() == Status.PROTOCOL_EXCEPTION) { | 547 | } else if (message.status() == Status.PROTOCOL_EXCEPTION) { |
548 | - callback.completeExceptionally(new MessagingException.ProcotolException()); | 548 | + callback.completeExceptionally(new MessagingException.ProtocolException()); |
549 | } | 549 | } |
550 | } else { | 550 | } else { |
551 | log.debug("Received a reply for message id:[{}]. " | 551 | log.debug("Received a reply for message id:[{}]. " | ... | ... |
... | @@ -588,7 +588,8 @@ public class EventuallyConsistentMapImpl<K, V> | ... | @@ -588,7 +588,8 @@ public class EventuallyConsistentMapImpl<K, V> |
588 | peer) | 588 | peer) |
589 | .whenComplete((result, error) -> { | 589 | .whenComplete((result, error) -> { |
590 | if (error != null) { | 590 | if (error != null) { |
591 | - log.debug("Failed to send anti-entropy advertisement to {}", peer, error); | 591 | + log.debug("Failed to send anti-entropy advertisement to {}: {}", |
592 | + peer, error.getMessage()); | ||
592 | } else if (result == AntiEntropyResponse.PROCESSED) { | 593 | } else if (result == AntiEntropyResponse.PROCESSED) { |
593 | antiEntropyTimes.put(peer, adCreationTime); | 594 | antiEntropyTimes.put(peer, adCreationTime); |
594 | } | 595 | } |
... | @@ -603,7 +604,8 @@ public class EventuallyConsistentMapImpl<K, V> | ... | @@ -603,7 +604,8 @@ public class EventuallyConsistentMapImpl<K, V> |
603 | peer) | 604 | peer) |
604 | .whenComplete((result, error) -> { | 605 | .whenComplete((result, error) -> { |
605 | if (error != null) { | 606 | if (error != null) { |
606 | - log.debug("Failed to send update request to {}", peer, error); | 607 | + log.debug("Failed to send update request to {}: {}", |
608 | + peer, error.getMessage()); | ||
607 | } | 609 | } |
608 | }); | 610 | }); |
609 | } | 611 | } | ... | ... |
-
Please register or login to post a comment