001/*
002 *  Copyright 2010 Media Service Provider Ltd
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License./*
015 */
016package org.apache.commons.daemon;
017
018/**
019 * Throw this during init if you can't initialize yourself for some expected reason. Using this exception will cause the
020 * exception's message to come out on stdout, rather than a dirty great stack trace.
021 */
022public class DaemonInitException extends Exception {
023
024    private static final long serialVersionUID = 5665891535067213551L;
025
026    /**
027     * Constructs a new exception with the given message.
028     *
029     * @param message the detail message accessible with {@link #getMessage()} .
030     */
031    public DaemonInitException(final String message) {
032        super(message);
033    }
034
035    /**
036     * Constructs a new exception with the given detail and cause.
037     *
038     * @param message the detail message accessible with {@link #getMessage()} .
039     * @param cause the cause accessible with {@link #getCause()}.
040     */
041    public DaemonInitException(final String message, final Throwable cause) {
042        super(message, cause);
043    }
044
045    /**
046     * Gets the message with the cause as a postfix.
047     *
048     * @return the message with the cause as a postfix.
049     */
050    public String getMessageWithCause() {
051        final Throwable cause = getCause();
052        return getMessage() + (cause == null ? "" : ": " + cause.getMessage());
053    }
054
055}