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.internal;
15 import java.io.IOException;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.io.transport.modbus.exception.ModbusSlaveIOException;
21 import net.wimpi.modbus.ModbusIOException;
24 * Exception for all IO errors
26 * @author Sami Salonen - Initial contribution
30 public class ModbusSlaveIOExceptionImpl extends ModbusSlaveIOException {
32 private static final long serialVersionUID = -8910463902857643468L;
33 private Exception error;
35 public ModbusSlaveIOExceptionImpl(ModbusIOException e) {
39 public ModbusSlaveIOExceptionImpl(IOException e) {
44 public @Nullable String getMessage() {
45 return String.format("Modbus IO Error with cause=%s, EOF=%s, message='%s', cause2=%s",
46 error.getClass().getSimpleName(),
47 error instanceof ModbusIOException ? ((ModbusIOException) error).isEOF() : "?", error.getMessage(),
52 public String toString() {
53 return String.format("ModbusSlaveIOException(cause=%s, EOF=%s, message='%s', cause2=%s)",
54 error.getClass().getSimpleName(),
55 error instanceof ModbusIOException ? ((ModbusIOException) error).isEOF() : "?", error.getMessage(),