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 *
016 */
017package org.apache.commons.daemon;
018
019/**
020 * Throw this during init if you can't initialize yourself for some expected reason. Using this exception will cause the
021 * exception's message to come out on stdout, rather than a dirty great stack trace.
022 */
023public class DaemonInitException extends Exception {
024
025    private static final long serialVersionUID = 5665891535067213551L;
026
027    /**
028     * Constructs a new exception with the given message.
029     *
030     * @param message the detail message accessible with {@link #getMessage()} .
031     */
032    public DaemonInitException(final String message) {
033        super(message);
034    }
035
036    /**
037     * Constructs a new exception with the given detail and cause.
038     *
039     * @param message the detail message accessible with {@link #getMessage()} .
040     * @param cause the cause accessible with {@link #getCause()}.
041     */
042    public DaemonInitException(final String message, final Throwable cause) {
043        super(message, cause);
044    }
045
046    /**
047     * Gets the message with the cause as a postfix.
048     *
049     * @return the message with the cause as a postfix.
050     */
051    public String getMessageWithCause() {
052        final Throwable cause = getCause();
053        return getMessage() + (cause == null ? "" : ": " + cause.getMessage());
054    }
055
056}