Package: DeviceCallSendException
DeviceCallSendException
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DeviceCallSendException(DeviceMessage) |
|
|
|
|
|
||||||||||||||||||||
DeviceCallSendException(Throwable, DeviceMessage) |
|
|
|
|
|
||||||||||||||||||||
getRequestMessage() |
|
|
|
|
|
Coverage
1: /*******************************************************************************
2: * Copyright (c) 2019, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.service.device.call.exception;
14:
15: import org.eclipse.kapua.service.device.call.message.DeviceMessage;
16:
17: import javax.validation.constraints.NotNull;
18:
19: /**
20: * The {@link Exception} to throw when sending the {@link DeviceMessage} causes an error.
21: *
22: * @since 1.1.0
23: */
24: public class DeviceCallSendException extends DeviceCallException {
25:
26: private final DeviceMessage<?, ?> requestMessage;
27: private final String causeMessage;
28:
29: /**
30: * Constructor.
31: *
32: * @param requestMessage The {@link DeviceMessage} that we tried to send.
33: * @since 1.1.0
34: */
35: public DeviceCallSendException(@NotNull DeviceMessage<?, ?> requestMessage) {
36: super(DeviceCallErrorCodes.SEND_ERROR, requestMessage);
37:
38: this.requestMessage = requestMessage;
39: this.causeMessage = null;
40: }
41:
42: /**
43: * Constructor.
44: *
45: * @param cause the root cause of the {@link Exception}.
46: * @param requestMessage The {@link DeviceMessage} that we tried to send.
47: * @since 1.1.0
48: */
49: public DeviceCallSendException(@NotNull Throwable cause, @NotNull DeviceMessage<?, ?> requestMessage) {
50: super(DeviceCallErrorCodes.SEND_ERROR_WITH_CAUSE, cause, requestMessage, cause.getMessage());
51:
52: this.requestMessage = requestMessage;
53: this.causeMessage = cause.getMessage();
54: }
55:
56: /**
57: * Gets the {@link DeviceMessage} that we tried to send.
58: *
59: * @return The {@link DeviceMessage} that we tried to send.
60: * @since 1.1.0
61: */
62: public DeviceMessage<?, ?> getRequestMessage() {
63: return requestMessage;
64: }
65: }