2 * Copyright (c) 2010-2020 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.io.transport.modbus.exception;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.io.transport.modbus.endpoint.ModbusSlaveEndpoint;
20 * Exception for connection issues
22 * @author Sami Salonen - Initial contribution
26 public class ModbusConnectionException extends ModbusTransportException {
28 private static final long serialVersionUID = -6171226761518661925L;
29 private ModbusSlaveEndpoint endpoint;
33 * @param endpoint endpoint associated with this exception
35 public ModbusConnectionException(ModbusSlaveEndpoint endpoint) {
36 this.endpoint = endpoint;
40 * Get endpoint associated with this connection error
42 * @return endpoint with the error
44 public ModbusSlaveEndpoint getEndpoint() {
49 public @Nullable String getMessage() {
50 return String.format("Error connecting to endpoint %s", endpoint);
54 public String toString() {
55 return String.format("ModbusConnectionException(Error connecting to endpoint=%s)", endpoint);