/*
 * @(#)SshException.java
 *
 * Copyright (c) 2001-2002 JScape
 * 1147 S. 53rd Pl., Mesa, Arizona, 85206, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * JScape. ("Confidential Information").  You shall not disclose such
 * Confidential Information and shall use it only in accordance with
 * the terms of the license agreement you entered into with JScape.
 */
package com.jscape.inet.ssh;

import com.jscape.util.SuppressObfuscation;

/**
 * SshException is thrown by many methods of Ssh class. The methods are
 * masking various exception types into SshException, but the event message
 * will be propagated.
 * <p/>
 * <P>
 * In case that the cause for throwing SshException is not exception but
 * invalid client operation or server response, SshException message will
 * contain textual part of server response.
 * </p>
 *
 * @author vglass
 */
@SuppressObfuscation
public class SshException
        extends Exception {

    private static final long serialVersionUID = 7563401463035256135L;

    public static SshException wrap(Throwable e) {
        return e instanceof SshException ? (SshException) e : new SshException(e);
    }

    public SshException() {
    }

    /**
     * Creates exception with specified message string.
     *
     * @param message the message of exception
     */
    public SshException(String message) {
        super(message);
    }

    /**
     * Creates exception with specified message string and source exception
     *
     * @param message   the message of exception
     * @param cause the exception which caused this exception
     */
    public SshException(String message, Throwable cause) {
        super(message, cause);
    }

    /**
     * Creates exception with specified message string and source exception
     *
     * @param cause the exception which caused this exception
     */
    public SshException(Throwable cause) {
        super(cause.getMessage() != null ? cause.getMessage() : cause.toString(), cause);
    }

}
