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.server.ops; 018 019import static org.apache.juneau.http.HttpMethod.*; 020 021import org.apache.juneau.rest.server.*; 022import org.apache.juneau.rest.server.servlet.*; 023 024/** 025 * Mixin providing the residual {@code [* /error]} endpoint. 026 * 027 * <p> 028 * Single-responsibility op-mixin carved out of the former {@code BasicRestOperations} interface. Compose 029 * into a host via {@link Rest#mixins() @Rest(mixins=ErrorMixin.class)}; the {@link BasicRestServlet} family 030 * pulls it in by default. 031 * 032 * <p> 033 * Servlet chains often redirect to {@code /error} when an error condition occurs (such as failed 034 * authentication) and set appropriate response parameters (such as a {@code WWW-Authenticate} header). 035 * 036 * @since 10.0.0 037 */ 038@Rest 039public class ErrorMixin extends RestMixin { 040 041 /** 042 * [* /error] - Error occurred. 043 */ 044 @RestOp( 045 method=ANY, 046 path="/error", 047 summary="Error occurred", 048 description={ 049 "An error occurred during handling of the request. ", 050 "Servlet chains will often automatically redirect to '/error' when any sort of error condition occurs ", 051 "(such as failed authentication) and will set appropriate response parameters ", 052 "(such as an WWW-Authenticate response header)." 053 } 054 ) 055 public void error() { /* intentionally empty — triggers the exception handler for all error conditions */ } 056}