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