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.net.ftp.parser;
019
020/**
021 * This class encapsulates all errors that may be thrown by
022 * the process of an FTPFileEntryParserFactory creating and
023 * instantiating an FTPFileEntryParser.
024 */
025public class ParserInitializationException extends RuntimeException {
026
027    /**
028     * Root exception that caused this to be thrown
029     */
030    private final Throwable rootCause;
031
032    /**
033     * Constucts a ParserInitializationException with just a message
034     *
035     * @param message Exception message
036     */
037    public ParserInitializationException(String message) {
038        super(message);
039        this.rootCause = null;
040    }
041
042    /**
043     * Constucts a ParserInitializationException with a message
044     * and a root cause.
045     *
046     * @param message   Exception message
047     * @param rootCause root cause throwable that caused
048     * this to be thrown
049     */
050    public ParserInitializationException(String message, Throwable rootCause) {
051        super(message);
052        this.rootCause = rootCause;
053    }
054
055    /**
056     * returns the root cause of this exception or null
057     * if no root cause was specified.
058     *
059     * @return the root cause of this exception being thrown
060     */
061    public Throwable getRootCause() {
062        return this.rootCause;
063    }
064
065}