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.arg;
018
019import static org.apache.juneau.commons.utils.Utils.*;
020
021import java.util.*;
022
023import org.apache.http.*;
024import org.apache.juneau.commons.reflect.*;
025import org.apache.juneau.http.*;
026import org.apache.juneau.http.header.*;
027import org.apache.juneau.http.response.*;
028
029/**
030 * General exception due to a malformed Java parameter.
031 *
032 * <h5 class='section'>See Also:</h5><ul>
033 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JavaMethodParameters">Java Method Parameters</a>
034 * </ul>
035 *
036 * @serial exclude
037 */
038public class ArgException extends InternalServerError {
039   private static final long serialVersionUID = 1L;
040
041   /**
042    * Constructor.
043    *
044    * @param pi The parameter with the issue.
045    * @param msg The message.
046    * @param args The message args.
047    */
048   public ArgException(ParameterInfo pi, String msg, Object...args) {
049      super(f(msg, args) + " on parameter " + pi.getIndex() + " of method " + pi.getMethod().getFullName() + ".");
050   }
051
052   /**
053    * Copy constructor.
054    *
055    * @param copyFrom The object to copy.
056    */
057   protected ArgException(ArgException copyFrom) {
058      super(copyFrom);
059   }
060
061   @Override /* Overridden from InternalServerError */
062   public ArgException copy() {
063      return new ArgException(this);
064   }
065
066   @Override /* Overridden from InternalServerError */
067   public ArgException setContent(HttpEntity value) {
068      super.setContent(value);
069      return this;
070   }
071
072   @Override /* Overridden from InternalServerError */
073   public ArgException setContent(String value) {
074      super.setContent(value);
075      return this;
076   }
077
078   @Override /* Overridden from InternalServerError */
079   public ArgException setHeader2(String name, Object value) {
080      super.setHeader2(name, value);
081      return this;
082   }
083
084   @Override /* Overridden from InternalServerError */
085   public ArgException setHeaders(HeaderList value) {
086      super.setHeaders(value);
087      return this;
088   }
089
090   @Override /* Overridden from InternalServerError */
091   public ArgException setHeaders(List<Header> values) {
092      super.setHeaders(values);
093      return this;
094   }
095
096   @Override /* Overridden from InternalServerError */
097   public ArgException setHeaders2(Header...values) {
098      super.setHeaders2(values);
099      return this;
100   }
101
102   @Override /* Overridden from InternalServerError */
103   public ArgException setLocale2(Locale value) {
104      super.setLocale2(value);
105      return this;
106   }
107
108   @Override /* Overridden from InternalServerError */
109   public ArgException setMessage(String message, Object...args) {
110      super.setMessage(message, args);
111      return this;
112   }
113
114   @Override /* Overridden from InternalServerError */
115   public ArgException setProtocolVersion(ProtocolVersion value) {
116      super.setProtocolVersion(value);
117      return this;
118   }
119
120   @Override /* Overridden from InternalServerError */
121   public ArgException setReasonPhrase2(String value) {
122      super.setReasonPhrase2(value);
123      return this;
124   }
125
126   @Override /* Overridden from InternalServerError */
127   public ArgException setReasonPhraseCatalog(ReasonPhraseCatalog value) {
128      super.setReasonPhraseCatalog(value);
129      return this;
130   }
131
132   @Override /* Overridden from InternalServerError */
133   public ArgException setStatusLine(BasicStatusLine value) {
134      super.setStatusLine(value);
135      return this;
136   }
137
138   @Override /* Overridden from InternalServerError */
139   public ArgException setUnmodifiable() {
140      super.setUnmodifiable();
141      return this;
142   }
143}