package net.northking.cctp.upperComputer.driver.usbmuxd;

import java.io.IOException;

public class UsbMuxdConnectFailedException extends IOException {

    private final String message;

    UsbMuxdConnectFailedException(String message, UsbMuxd.ConnectType connectType, String path, String host, int port) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(message);
        switch (connectType) {

            case UNIX_SOCKET:
                stringBuilder.append(" [UNIX_SOCKET] ");
                stringBuilder.append(path);
                break;
            case NETWORK :
                stringBuilder.append(" [NETWORK] 主机:");
                stringBuilder.append(host);
                stringBuilder.append(" 端口:");
                stringBuilder.append(port);
                break;
        }

        stringBuilder.append(" 无法连接");
        this.message = stringBuilder.toString();
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public String getLocalizedMessage() {
        return message;
    }
}
