]> git.basschouten.com Git - openhab-addons.git/blob
ebd6c6ec00cb526c4978722a63cb8291a29df220
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.io.transport.modbus.exception;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.io.transport.modbus.endpoint.ModbusSlaveEndpoint;
17
18 /**
19  * Exception for connection issues
20  *
21  * @author Sami Salonen - Initial contribution
22  *
23  */
24 @NonNullByDefault
25 public class ModbusConnectionException extends ModbusTransportException {
26
27     private static final long serialVersionUID = -6171226761518661925L;
28     private ModbusSlaveEndpoint endpoint;
29
30     /**
31      *
32      * @param endpoint endpoint associated with this exception
33      */
34     public ModbusConnectionException(ModbusSlaveEndpoint endpoint) {
35         this.endpoint = endpoint;
36     }
37
38     /**
39      * Get endpoint associated with this connection error
40      *
41      * @return endpoint with the error
42      */
43     public ModbusSlaveEndpoint getEndpoint() {
44         return endpoint;
45     }
46
47     @Override
48     public String getMessage() {
49         return String.format("Error connecting to endpoint %s", endpoint);
50     }
51
52     @Override
53     public String toString() {
54         return String.format("ModbusConnectionException(Error connecting to endpoint=%s)", endpoint);
55     }
56 }