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     */
025    public class DaemonInitException extends Exception {
026    
027      //don't rely on Throwable#getCause (jdk1.4)
028      private final Throwable cause;
029    
030      public DaemonInitException(String message) {
031        super(message);
032        this.cause = null;
033      }
034    
035      public DaemonInitException(String message, Throwable cause) {
036        super(message);
037        this.cause = cause;
038      }
039    
040      public String getMessageWithCause() {
041        String extra = this.cause == null ? "" : ": " + this.cause.getMessage();
042        return getMessage() + extra;
043      }
044    
045    }