Skip to content

Commit

Permalink
Added SEND_ERROR_WITH_CAUSE to DeviceCallErrorCodes
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Codutti <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Aug 2, 2023
1 parent 4f489c6 commit bae954f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public enum DeviceCallErrorCodes implements KapuaErrorCode {
*/
SEND_ERROR,

/**
* @see DeviceCallSendException
* @since 2.0.0
*/
SEND_ERROR_WITH_CAUSE,

/**
* @see DeviceCallTimeoutException
* @since 1.1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@
*/
public class DeviceCallSendException extends DeviceCallException {

private final DeviceMessage requestMessage;
private final DeviceMessage<?, ?> requestMessage;
private final String causeMessage;

/**
* Constructor.
*
* @param requestMessage The {@link DeviceMessage} that we tried to send.
* @since 1.1.0
*/
public DeviceCallSendException(@NotNull DeviceMessage requestMessage) {
public DeviceCallSendException(@NotNull DeviceMessage<?, ?> requestMessage) {
super(DeviceCallErrorCodes.SEND_ERROR, requestMessage);

this.requestMessage = requestMessage;
this.causeMessage = null;
}

/**
Expand All @@ -43,9 +46,11 @@ public DeviceCallSendException(@NotNull DeviceMessage requestMessage) {
* @param requestMessage The {@link DeviceMessage} that we tried to send.
* @since 1.1.0
*/
public DeviceCallSendException(@NotNull Throwable cause, @NotNull DeviceMessage requestMessage) {
super(DeviceCallErrorCodes.SEND_ERROR, cause, requestMessage);
public DeviceCallSendException(@NotNull Throwable cause, @NotNull DeviceMessage<?, ?> requestMessage) {
super(DeviceCallErrorCodes.SEND_ERROR_WITH_CAUSE, cause, requestMessage, cause.getMessage());

this.requestMessage = requestMessage;
this.causeMessage = cause.getMessage();
}

/**
Expand All @@ -54,7 +59,7 @@ public DeviceCallSendException(@NotNull Throwable cause, @NotNull DeviceMessage
* @return The {@link DeviceMessage} that we tried to send.
* @since 1.1.0
*/
public DeviceMessage getRequestMessage() {
public DeviceMessage<?, ?> getRequestMessage() {
return requestMessage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
#
###############################################################################
SEND_ERROR=An error occurred when sending the message: {0}
SEND_ERROR_WITH_CAUSE=An error occurred when sending the message: {0}. Caused by: {1}
TIMEOUT=The request has not received a response within the timeout of: {0}ms

0 comments on commit bae954f

Please sign in to comment.