<commit_before>/*
 * 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.core.impl.filter;

import java.io.IOException;
import java.util.Iterator;

import javax.servlet.http.HttpServletResponse;

import org.apache.sling.component.Component;
import org.apache.sling.component.ComponentException;
import org.apache.sling.component.ComponentFilterChain;
import org.apache.sling.component.ComponentRequest;
import org.apache.sling.component.ComponentResponse;
import org.apache.sling.component.ComponentResponseWrapper;
import org.apache.sling.core.Constants;
import org.apache.sling.core.components.ErrorHandlerComponent;
import org.apache.sling.core.impl.ContentData;
import org.apache.sling.core.impl.RequestData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * The <code>ErrorHandlerFilter</code> TODO
 *
 * @scr.component immediate="true" label="%errhandler.name"
 *      description="%errhandler.description"
 * @scr.property name="service.description" value="Error Handler Filter"
 * @scr.property name="service.vendor" value="The Apache Software Foundation"
 * @scr.property name="filter.scope" value="request" private="true"
 * @scr.property name="filter.order" value="-1000" type="Integer" private="true"
 * @scr.service
 * @scr.reference name="Components" interface="org.apache.sling.component.Component"
 *                cardinality="0..n" policy="dynamic"
 */
public class ErrorHandlerFilter extends ComponentBindingFilter {

    /** default log */
    private static final Logger log = LoggerFactory.getLogger(ErrorHandlerFilter.class);

    public void doFilter(ComponentRequest request, ComponentResponse response,
            ComponentFilterChain filterChain) throws IOException,
            ComponentException {

        try {
            filterChain.doFilter(request, new ErrorHandlerResponse(request,
                response));
        } catch (Throwable throwable) {
            this.handleError(throwable, request, response);
        }

    }

    protected boolean accept(Component component) {<commit_msg>Log an exception to the log to see the errors in all cases.<commit_after>/*
 * 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.core.impl.filter;

import java.io.IOException;
import java.util.Iterator;

import javax.servlet.http.HttpServletResponse;

import org.apache.sling.component.Component;
import org.apache.sling.component.ComponentException;
import org.apache.sling.component.ComponentFilterChain;
import org.apache.sling.component.ComponentRequest;
import org.apache.sling.component.ComponentResponse;
import org.apache.sling.component.ComponentResponseWrapper;
import org.apache.sling.core.Constants;
import org.apache.sling.core.components.ErrorHandlerComponent;
import org.apache.sling.core.impl.ContentData;
import org.apache.sling.core.impl.RequestData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * The <code>ErrorHandlerFilter</code> TODO
 *
 * @scr.component immediate="true" label="%errhandler.name"
 *      description="%errhandler.description"
 * @scr.property name="service.description" value="Error Handler Filter"
 * @scr.property name="service.vendor" value="The Apache Software Foundation"
 * @scr.property name="filter.scope" value="request" private="true"
 * @scr.property name="filter.order" value="-1000" type="Integer" private="true"
 * @scr.service
 * @scr.reference name="Components" interface="org.apache.sling.component.Component"
 *                cardinality="0..n" policy="dynamic"
 */
public class ErrorHandlerFilter extends ComponentBindingFilter {

    /** default log */
    private static final Logger log = LoggerFactory.getLogger(ErrorHandlerFilter.class);

    public void doFilter(ComponentRequest request, ComponentResponse response,
            ComponentFilterChain filterChain) throws IOException,
            ComponentException {

        try {
            filterChain.doFilter(request, new ErrorHandlerResponse(request,
                response));
        } catch (Throwable throwable) {
            log.error("Error during request processing.", throwable);
            this.handleError(throwable, request, response);
        }

    }

    protected boolean accept(Component component) {
{'fraction_non_alphanumeric': 0.09607366226546213, 'fraction_numerical': 0.003822098679638638, 'mean_word_length': 4.228882833787466, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5046468', 'n_tokens_mistral': 1487, 'n_tokens_neox': 1462, 'n_words': 451}