001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 * 
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 * 
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.apache.commons.io;
019
020import java.io.IOException;
021
022/**
023 * Subclasses IOException with the {@link Throwable} constructors missing before Java 6. If you are using Java 6,
024 * consider this class deprecated and use {@link IOException}.
025 * 
026 * @version $Id: IOExceptionWithCause.java 1307459 2012-03-30 15:11:44Z ggregory $
027 * @since 1.4
028 */
029public class IOExceptionWithCause extends IOException {
030
031    /**
032     * Defines the serial version UID.
033     */
034    private static final long serialVersionUID = 1L;
035
036    /**
037     * Constructs a new instance with the given message and cause.
038     * <p>
039     * As specified in {@link Throwable}, the message in the given <code>cause</code> is not used in this instance's
040     * message.
041     * </p>
042     * 
043     * @param message
044     *            the message (see {@link #getMessage()})
045     * @param cause
046     *            the cause (see {@link #getCause()}). A {@code null} value is allowed.
047     */
048    public IOExceptionWithCause(String message, Throwable cause) {
049        super(message);
050        this.initCause(cause);
051    }
052
053    /**
054     * Constructs a new instance with the given cause.
055     * <p>
056     * The message is set to <code>cause==null ? null : cause.toString()</code>, which by default contains the class
057     * and message of <code>cause</code>. This constructor is useful for call sites that just wrap another throwable.
058     * </p>
059     * 
060     * @param cause
061     *            the cause (see {@link #getCause()}). A {@code null} value is allowed.
062     */
063    public IOExceptionWithCause(Throwable cause) {
064        super(cause == null ? null : cause.toString());
065        this.initCause(cause);
066    }
067
068}