001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.xbean.server.main; 018 019 /** 020 * Indicates that a fatal error occured while starting the server. 021 * @author Dain Sundstrom 022 * @version $Id$ 023 * @since 2.0 024 */ 025 public class FatalStartupError extends Error { 026 /** 027 * The default exit code assigned to new exception if an exit code is not provided. 028 */ 029 public static final int DEFAULT_EXIT_CODE = 3; 030 031 private final int exitCode; 032 033 /** 034 * Creates a FatalStartupError containing the specified message and the DEFAULT_EXIT_CODE. 035 * @param message a descrption of the cause of the error 036 */ 037 public FatalStartupError(String message) { 038 this(message, DEFAULT_EXIT_CODE); 039 } 040 041 /** 042 * Creates a FatalStartupError containing the specified message and exit code. 043 * @param message a descrption of the cause of the error 044 * @param exitCode the exit code that should be passed to System.exit(int) 045 */ 046 public FatalStartupError(String message, int exitCode) { 047 super(message); 048 this.exitCode = exitCode; 049 } 050 051 /** 052 * Creates a FatalStartupError containing the specified message, cause by exception, and the DEFAULT_EXIT_CODE. 053 * @param message a descrption of the cause of the error 054 * @param cause the cause of this exception 055 */ 056 public FatalStartupError(String message, Throwable cause) { 057 this(message, DEFAULT_EXIT_CODE, cause); 058 } 059 060 /** 061 * Creates a FatalStartupError containing the specified message, cause by exception, and the specified exit code. 062 * @param message a descrption of the cause of the error 063 * @param exitCode the exit code that should be passed to System.exit(int) 064 * @param cause the cause of this exception 065 */ 066 public FatalStartupError(String message, int exitCode, Throwable cause) { 067 super(message, cause); 068 this.exitCode = exitCode; 069 } 070 071 /** 072 * Gets the number that should be passed to System.exit(int) when the virtual machine is halted. 073 * @return the exit code that should be passed to System.exit(int) 074 */ 075 public int getExitCode() { 076 return exitCode; 077 } 078 }