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.codec;
019
020/**
021 * Thrown when there is a failure condition during the decoding process. This exception is thrown when a {@link Decoder}
022 * encounters a decoding specific exception such as invalid data, or characters outside of the expected range.
023 */
024public class DecoderException extends Exception {
025
026    /**
027     * Declares the Serial Version Uid.
028     *
029     * @see <a href="https://c2.com/cgi/wiki?AlwaysDeclareSerialVersionUid">Always Declare Serial Version Uid</a>
030     */
031    private static final long serialVersionUID = 1L;
032
033    /**
034     * Constructs a new exception with {@code null} as its detail message. The cause is not initialized, and may
035     * subsequently be initialized by a call to {@link #initCause}.
036     *
037     * @since 1.4
038     */
039    public DecoderException() {
040    }
041
042    /**
043     * Constructs a new exception with the specified detail message. The cause is not initialized, and may subsequently
044     * be initialized by a call to {@link #initCause}.
045     *
046     * @param message
047     *            The detail message which is saved for later retrieval by the {@link #getMessage()} method.
048     */
049    public DecoderException(final String message) {
050        super(message);
051    }
052
053    /**
054     * Constructs a new exception with the specified detail message and cause.
055     * <p>
056     * Note that the detail message associated with {@code cause} is not automatically incorporated into this
057     * exception's detail message.
058     * </p>
059     *
060     * @param message
061     *            The detail message which is saved for later retrieval by the {@link #getMessage()} method.
062     * @param cause
063     *            The cause which is saved for later retrieval by the {@link #getCause()} method. A {@code null}
064     *            value is permitted, and indicates that the cause is nonexistent or unknown.
065     * @since 1.4
066     */
067    public DecoderException(final String message, final Throwable cause) {
068        super(message, cause);
069    }
070
071    /**
072     * Constructs a new exception with the specified cause and a detail message of <code>(cause==null ?
073     * null : cause.toString())</code> (which typically contains the class and detail message of {@code cause}).
074     * This constructor is useful for exceptions that are little more than wrappers for other throwables.
075     *
076     * @param cause
077     *            The cause which is saved for later retrieval by the {@link #getCause()} method. A {@code null}
078     *            value is permitted, and indicates that the cause is nonexistent or unknown.
079     * @since 1.4
080     */
081    public DecoderException(final Throwable cause) {
082        super(cause);
083    }
084}