2 * Copyright (c) 2010-2023 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.groupepsa.internal.rest.exceptions;
15 import java.io.IOException;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
21 * An exception that occurred while communicating with a groupepsa or a groupepsa bridge
23 * @author Arjan Mels - Initial contribution
26 public class GroupePSACommunicationException extends IOException {
27 private static final long serialVersionUID = 1L;
28 private int statusCode = -1;
30 public GroupePSACommunicationException(Exception e) {
34 public GroupePSACommunicationException(int statusCode, Exception e) {
36 this.statusCode = statusCode;
39 public GroupePSACommunicationException(int statusCode) {
40 this.statusCode = statusCode;
43 public GroupePSACommunicationException(int statusCode, String message) {
45 this.statusCode = statusCode;
48 public GroupePSACommunicationException(String message, Exception e) {
52 public GroupePSACommunicationException(String message) {
56 public int getStatusCode() {
61 public @Nullable String getMessage() {
62 String message = super.getMessage();
63 return message == null ? null : "Rest call failed: statusCode=" + statusCode + ", message=" + message;
67 public String toString() {
68 return getClass().getSimpleName() + ": statusCode=" + statusCode + ", message=" + super.getMessage()
69 + ", cause: " + getCause();