This is an automated email from the ASF dual-hosted git repository. olli pushed a commit to branch SLING-11728 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-api.git
commit 330d143da37eb720e2c15fb4c3a1e171b48c7d69 Author: Oliver Lietz <[email protected]> AuthorDate: Mon Dec 12 12:04:36 2022 +0100 SLING-11728 Remove bi-directional dependencies between Engine and Servlets Resolver copy ErrorHandler from org.apache.sling.engine.servlets to org.apache.sling.api.servlets --- .../apache/sling/api/servlets/ErrorHandler.java | 72 ++++++++++++++++++++++ .../apache/sling/api/servlets/package-info.java | 2 +- 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/sling/api/servlets/ErrorHandler.java b/src/main/java/org/apache/sling/api/servlets/ErrorHandler.java new file mode 100644 index 0000000..c448739 --- /dev/null +++ b/src/main/java/org/apache/sling/api/servlets/ErrorHandler.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sling.api.servlets; + +import java.io.IOException; + +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.SlingHttpServletResponse; +import org.osgi.annotation.versioning.ConsumerType; + +/** + * The <code>ErrorHandler</code> defines the interface of the service used by + * the Sling to handle calls to <code>HttpServletResponse.sendError</code> and + * to handle uncaught <code>Throwable</code>s. + */ +@ConsumerType +public interface ErrorHandler { + + /** + * Called to render a response for a HTTP status code. This method should + * set the response status and print the status code and optional message. + * <p> + * If the response has already been committed, an error message should be + * logged but no further processing should take place. + * + * @param status The HTTP status code to set + * @param message An optional message to write to the response. This message + * may be <code>null</code>. + * @param request The request object providing more information on the + * request. + * @param response The response object used to send the status and message. + * @throws IOException May be thrown if an error occurrs sending the + * response. + */ + void handleError(int status, String message, + SlingHttpServletRequest request, SlingHttpServletResponse response) + throws IOException; + + /** + * Called to render a response for an uncaught <code>Throwable</code>. + * <p> + * If the response has already been committed, an error message should be + * logged but no further processing should take place. + * + * @param throwable The <code>Throwable</code> causing this method to be + * called. + * @param request The request object providing more information on the + * request. + * @param response The response object used to send the status and message. + * @throws IOException May be thrown if an error occurrs sending the + * response. + */ + void handleError(Throwable throwable, SlingHttpServletRequest request, + SlingHttpServletResponse response) throws IOException; + +} diff --git a/src/main/java/org/apache/sling/api/servlets/package-info.java b/src/main/java/org/apache/sling/api/servlets/package-info.java index df624e8..9c31c3e 100644 --- a/src/main/java/org/apache/sling/api/servlets/package-info.java +++ b/src/main/java/org/apache/sling/api/servlets/package-info.java @@ -17,7 +17,7 @@ * under the License. */ -@Version("2.3.1") +@Version("2.4.0") package org.apache.sling.api.servlets; import org.osgi.annotation.versioning.Version;
