2 * Copyright (c) 2010-2024 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.nibeuplink.internal.connector;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.eclipse.jetty.http.HttpStatus.Code;
20 * this class contains the HTTP status of the communication and an optional exception that might occoured during
23 * @author Alexander Friese - initial contribution
26 public class CommunicationStatus {
28 private @Nullable Code httpCode;
29 private @Nullable Exception error;
31 public final Code getHttpCode() {
33 return code == null ? Code.INTERNAL_SERVER_ERROR : code;
36 public final void setHttpCode(Code httpCode) {
37 this.httpCode = httpCode;
40 public final @Nullable Exception getError() {
44 public final void setError(Exception error) {
48 public final String getMessage() {
49 Exception err = error;
50 String errMsg = err == null ? null : err.getMessage();
51 String msg = getHttpCode().getMessage();
52 if (errMsg != null && !errMsg.isEmpty()) {
54 } else if (msg != null && !msg.isEmpty()) {