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     */
017    package org.apache.commons.daemon;
018    
019    /**
020     * Throw this during init if you can't initialise yourself for some expected 
021     * reason.  Using this exception will cause the exception's message to come out
022     * on stdout, rather than a dirty great stacktrace.
023     * @author Nick Griffiths (nicobrevin@gmail.com)
024     * @version $Id: DaemonInitException.java 1204007 2011-11-19 16:10:29Z ggregory $
025     */
026    public class DaemonInitException extends Exception {
027    
028      //don't rely on Throwable#getCause (jdk1.4)
029      private final Throwable cause;
030    
031      public DaemonInitException(String message) {
032        super(message);
033        this.cause = null;
034      }
035    
036      public DaemonInitException(String message, Throwable cause) {
037        super(message);
038        this.cause = cause;
039      }
040    
041      public String getMessageWithCause() {
042        String extra = this.cause == null ? "" : ": " + this.cause.getMessage();
043        return getMessage() + extra;
044      }
045    
046    }