/*
 * @(#)FileTransferException.java
 *
 * Copyright (c) 1999-2007 JSCAPE LLC
 *
 * 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.filetransfer;

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

    private static final long serialVersionUID = -3067153238481652621L;

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

    /**
     * Creates a new exception instance.
     */
    public FileTransferException() {
        // empty
    }

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

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

    /**
     * Constructor .
     *
     * @param cause - Exception
     */
    public FileTransferException(Throwable cause) {
        super(cause.getMessage() != null ? cause.getMessage() : cause.toString(), cause);
    }

}
