1 /* 2 * Copyright 2010 Media Service Provider Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License./* 15 */ 16 package org.apache.commons.daemon; 17 18 /** 19 * Throw this during init if you can't initialize yourself for some expected reason. Using this exception will cause the 20 * exception's message to come out on stdout, rather than a dirty great stack trace. 21 */ 22 public class DaemonInitException extends Exception { 23 24 private static final long serialVersionUID = 5665891535067213551L; 25 26 /** 27 * Constructs a new exception with the given message. 28 * 29 * @param message the detail message accessible with {@link #getMessage()} . 30 */ 31 public DaemonInitException(final String message) { 32 super(message); 33 } 34 35 /** 36 * Constructs a new exception with the given detail and cause. 37 * 38 * @param message the detail message accessible with {@link #getMessage()} . 39 * @param cause the cause accessible with {@link #getCause()}. 40 */ 41 public DaemonInitException(final String message, final Throwable cause) { 42 super(message, cause); 43 } 44 45 /** 46 * Gets the message with the cause as a postfix. 47 * 48 * @return the message with the cause as a postfix. 49 */ 50 public String getMessageWithCause() { 51 final Throwable cause = getCause(); 52 return getMessage() + (cause == null ? "" : ": " + cause.getMessage()); 53 } 54 55 }