Skip to content

Package: InvalidBodyContentException

InvalidBodyContentException

nameinstructionbranchcomplexitylinemethod
InvalidBodyContentException(Throwable, Class, String)
M: 21 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
InvalidBodyContentException(Throwable, Class, byte[])
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getBodyString()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getType()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2021, 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.translator.exception;
14:
15: import org.eclipse.kapua.message.Payload;
16:
17: /**
18: * {@link Exception} to {@code throw} when there is an error while translating a {@link Payload} body to a given type.
19: *
20: * @since 1.5.0
21: */
22: public class InvalidBodyContentException extends InvalidBodyException {
23:
24: private static final long serialVersionUID = -4616416494412835320L;
25:
26: private final Class<?> type;
27: private final String bodyString;
28:
29: /**
30: * Constructor.
31: *
32: * @param cause The {@link Throwable} cause of the error.
33: * @param type The {@link Class} in which to serialize the given body.
34: * @param body The body {@link Payload} which translation has caused the error.
35: * @since 1.5.0
36: */
37: public InvalidBodyContentException(Throwable cause, Class<?> type, byte[] body) {
38: this(cause, type, new String(body));
39: }
40:
41: /**
42: * Constructor.
43: *
44: * @param cause The {@link Throwable} cause of the error.
45: * @param type The {@link Class} in which to serialize the given body.
46: * @param bodyString The {@link String} encoded body {@link Payload}which translation has caused the error.
47: * @since 1.5.0
48: */
49: public InvalidBodyContentException(Throwable cause, Class<?> type, String bodyString) {
50: super(TranslatorErrorCodes.INVALID_BODY_CONTENT, cause, type, bodyString);
51:
52: this.type = type;
53: this.bodyString = bodyString;
54: }
55:
56: /**
57: * Gets the {@link Class} type.
58: *
59: * @return The {@link Class} type.
60: * @since 1.5.0
61: */
62: public Class<?> getType() {
63: return type;
64: }
65:
66: /**
67: * Gets the {@link Payload}'s body which cannot be translated.
68: *
69: * @return The {@link Payload}'s body which cannot be translated.
70: * @since 1.5.0
71: */
72: public String getBodyString() {
73: return bodyString;
74: }
75: }