001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau; 014 015import java.text.*; 016 017/** 018 * An exception that typically occurs when trying to perform an invalid operation on a configuration property. 019 */ 020public class ConfigException extends FormattedRuntimeException { 021 private static final long serialVersionUID = 1L; 022 023 /** 024 * Constructor 025 * 026 * @param message The error message. 027 * @param args Optional {@link MessageFormat}-style arguments. 028 */ 029 public ConfigException(String message, Object...args) { 030 super(message, args); 031 } 032 033 /** 034 * Constructor 035 * 036 * @param t The init cause. Can be <jk>null</jk>. 037 * @param message The error message. 038 * @param args Optional {@link MessageFormat}-style arguments. 039 */ 040 public ConfigException(Throwable t, String message, Object...args) { 041 super(t, message, args); 042 } 043 044 @Override 045 public String getMessage() { 046 Throwable t = getCause(); 047 if (t == null) 048 return super.getMessage(); 049 StringBuilder sb = new StringBuilder(super.getMessage()); 050 while (t != null) { 051 sb.append(" ").append(t.getMessage()); 052 t = t.getCause(); 053 } 054 return sb.toString(); 055 } 056}