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.automower.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 an automower or an automower bridge
23 * @author Markus Pfleger - Initial contribution
26 public class AutomowerCommunicationException extends IOException {
27 private static final long serialVersionUID = 1L;
28 private int statusCode = -1;
30 public AutomowerCommunicationException(Exception e) {
34 public AutomowerCommunicationException(int statusCode, Exception e) {
36 this.statusCode = statusCode;
39 public AutomowerCommunicationException(int statusCode) {
40 this.statusCode = statusCode;
43 public AutomowerCommunicationException(int statusCode, String message) {
45 this.statusCode = statusCode;
48 public AutomowerCommunicationException(String message, Exception e) {
52 public AutomowerCommunicationException(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();