1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package org.apache.commons.io;
19
20import java.io.IOException;
21
22/**
23 * Subclasses IOException with the {@link Throwable} constructors missing before Java 6. If you are using Java 6,
24 * consider this class deprecated and use {@link IOException}.
25 *
26 * @author <a href="http://commons.apache.org/io/">Apache Commons IO</a>
27 * @version $Id$
28 * @since Commons IO 1.4
29 */
30public class IOExceptionWithCause extends IOException {
31
32    /**
33     * Defines the serial version UID.
34     */
35    private static final long serialVersionUID = 1L;
36
37    /**
38     * Constructs a new instance with the given message and cause.
39     * <p>
40     * As specified in {@link Throwable}, the message in the given <code>cause</code> is not used in this instance's
41     * message.
42     * </p>
43     *
44     * @param message
45     *            the message (see {@link #getMessage()})
46     * @param cause
47     *            the cause (see {@link #getCause()}). A <code>null</code> value is allowed.
48     */
49    public IOExceptionWithCause(String message, Throwable cause) {
50        super(message);
51        this.initCause(cause);
52    }
53
54    /**
55     * Constructs a new instance with the given cause.
56     * <p>
57     * The message is set to <code>cause==null ? null : cause.toString()</code>, which by default contains the class
58     * and message of <code>cause</code>. This constructor is useful for call sites that just wrap another throwable.
59     * </p>
60     *
61     * @param cause
62     *            the cause (see {@link #getCause()}). A <code>null</code> value is allowed.
63     */
64    public IOExceptionWithCause(Throwable cause) {
65        super(cause == null ? null : cause.toString());
66        this.initCause(cause);
67    }
68
69}
70