Skip to content

Package: InvalidBodyEncodingException

InvalidBodyEncodingException

nameinstructionbranchcomplexitylinemethod
InvalidBodyEncodingException(Throwable, String, byte[])
M: 24 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getBody()
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%
getEncoding()
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: import java.util.Arrays;
18:
19: /**
20: * {@link Exception} to {@code throw} when there is an error while translating a {@link Payload} body with a given encoding.
21: *
22: * @since 1.5.0
23: */
24: public class InvalidBodyEncodingException extends InvalidBodyException {
25:
26: private static final long serialVersionUID = 5520533060394828471L;
27:
28: private final String encoding;
29: private final byte[] body;
30:
31: /**
32: * Constructor.
33: *
34: * @param cause The {@link Throwable} cause of the error.
35: * @param body The body {@link Payload} which translation has caused the error.
36: * @since 1.5.0
37: */
38: public InvalidBodyEncodingException(Throwable cause, String encoding, byte[] body) {
39: super(TranslatorErrorCodes.INVALID_BODY_ENCODING, cause, encoding, Arrays.toString(Arrays.copyOf(body, 64)));
40:
41: this.encoding = encoding;
42: this.body = body;
43: }
44:
45: /**
46: * Gets the target encoding.
47: *
48: * @return The target encoding.
49: * @since 1.5.0
50: */
51: public String getEncoding() {
52: return encoding;
53: }
54:
55: /**
56: * Gets the {@link Payload}'s body which cannot be translated
57: *
58: * @return The {@link Payload}'s body which cannot be translated
59: */
60: public byte[] getBody() {
61: return body;
62: }
63: }