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 */ 017package org.apache.juneau.rest.client.remote; 018 019import static org.apache.juneau.commons.utils.Utils.*; 020 021import java.lang.reflect.*; 022import java.text.*; 023 024import org.apache.juneau.*; 025 026/** 027 * Exceptions caused by invalid REST proxy classes. 028 * 029 * <h5 class='section'>See Also:</h5><ul> 030 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/RestProxyBasics">REST Proxy Basics</a> 031 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauRestClientBasics">juneau-rest-client Basics</a> 032 * </ul> 033 * 034 * @serial exclude 035 */ 036public class RemoteMetadataException extends BasicRuntimeException { 037 038 private static final long serialVersionUID = 1L; 039 040 private static final String getMessage(Class<?> c, Method m, String msg) { 041 var sb = new StringBuilder("Invalid remote definition found on class ").append(c.getName()); 042 if (nn(m)) 043 sb.append(" on method ").append(m.getName()); 044 sb.append(". ").append(msg); 045 return sb.toString(); 046 } 047 048 /** 049 * Constructor. 050 * 051 * @param c The interface class that has an invalid definition. 052 * @param message The {@link MessageFormat}-style message. 053 * @param args Optional {@link MessageFormat}-style arguments. 054 */ 055 public RemoteMetadataException(Class<?> c, String message, Object...args) { 056 this((Throwable)null, getMessage(c, null, message), args); 057 } 058 059 /** 060 * Constructor. 061 * 062 * @param m The interface method that has an invalid definition. 063 * @param message The {@link MessageFormat}-style message. 064 * @param args Optional {@link MessageFormat}-style arguments. 065 */ 066 public RemoteMetadataException(Method m, String message, Object...args) { 067 this((Throwable)null, getMessage(m.getDeclaringClass(), m, message), args); 068 } 069 070 /** 071 * Constructor. 072 * 073 * @param cause The cause of this exception. 074 * @param message The {@link MessageFormat}-style message. 075 * @param args Optional {@link MessageFormat}-style arguments. 076 */ 077 public RemoteMetadataException(Throwable cause, String message, Object...args) { 078 super(cause, message, args); 079 } 080 081 @Override /* Overridden from BasicRuntimeException */ 082 public RemoteMetadataException setMessage(String message, Object...args) { 083 super.setMessage(message, args); 084 return this; 085 } 086}