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.http.exception; 014 015import static org.apache.juneau.http.exception.ExpectationFailed.*; 016 017import java.text.*; 018 019import org.apache.juneau.http.annotation.*; 020 021/** 022 * Exception representing an HTTP 417 (Expectation Failed). 023 * 024 * <p> 025 * The server cannot meet the requirements of the Expect request-header field. 026 */ 027@Response(code=CODE, description=MESSAGE) 028public class ExpectationFailed extends HttpException { 029 private static final long serialVersionUID = 1L; 030 031 /** HTTP status code */ 032 public static final int CODE = 417; 033 034 /** Default message */ 035 public static final String MESSAGE = "Expectation Failed"; 036 037 /** 038 * Constructor. 039 * 040 * @param cause The cause. Can be <jk>null</jk>. 041 * @param msg The message. Can be <jk>null</jk>. 042 * @param args Optional {@link MessageFormat}-style arguments in the message. 043 */ 044 public ExpectationFailed(Throwable cause, String msg, Object...args) { 045 super(cause, CODE, msg, args); 046 } 047 048 /** 049 * Constructor. 050 * 051 * @param msg The message. Can be <jk>null</jk>. 052 */ 053 public ExpectationFailed(String msg) { 054 super(msg); 055 setStatus(CODE); 056 } 057 058 /** 059 * Constructor. 060 */ 061 public ExpectationFailed() { 062 this((Throwable)null, MESSAGE); 063 } 064 065 /** 066 * Constructor. 067 * 068 * @param msg The message. Can be <jk>null</jk>. 069 * @param args Optional {@link MessageFormat}-style arguments in the message. 070 */ 071 public ExpectationFailed(String msg, Object...args) { 072 this(null, msg, args); 073 } 074 075 /** 076 * Constructor. 077 * 078 * @param cause The cause. Can be <jk>null</jk>. 079 */ 080 public ExpectationFailed(Throwable cause) { 081 this(cause, null); 082 } 083}