<commit_before><?php
/*  This file is part of Syj, Copyright (c) 2010 <NAME>,
    and is published under the AGPL license. */

class ErrorController extends Zend_Controller_Action
{
    protected function httpError($code) {
        $this->getResponse()->setHttpResponseCode($code);
    }

    public function init() {
        $this->_helper->SyjReset->resetPlaceHolders();
        $this->view->headLink()->appendStylesheet('css/generic.css', 'all');
        $this->view->headLink()->appendStylesheet('css/error.css', 'all');
    }

    public function errorAction() {
        $error = $this->_getParam('error_handler');

        $error_code = 500; // default value: Internal Server Error
        switch ($error->type) {
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
                $error_code = 404; // Not Found
                break;
            default:
                if ($error->exception instanceof Syj_Exception_Request) {
                    $error_code = 400; // Bad Request
                } else if ($error->exception instanceof Syj_Exception_Forbidden) {
                    $error_code = 403; // Forbidden
                } else if ($error->exception instanceof Syj_Exception_NotFound) {
                    $error_code = $error->exception->getCode();
                }
                break;
        }
        $this->httpError($error_code);

        // Log exception, if logger available
        if ($log = $this->getLog()) {
            $log->crit($this->view->message, $error->exception);
        }

        if ($error_code != 404 and $error_code != 410 and $error->request->isXmlHttpRequest()) {
            return $this->_helper->json(array('message' => $error->exception->getMessage()));
        }

        // conditionally display exceptions<commit_msg>output error message only if error code is 400<commit_after><?php
/*  This file is part of Syj, Copyright (c) 2010 <NAME>,
    and is published under the AGPL license. */

class ErrorController extends Zend_Controller_Action
{
    protected function httpError($code) {
        $this->getResponse()->setHttpResponseCode($code);
    }

    public function init() {
        $this->_helper->SyjReset->resetPlaceHolders();
        $this->view->headLink()->appendStylesheet('css/generic.css', 'all');
        $this->view->headLink()->appendStylesheet('css/error.css', 'all');
    }

    public function errorAction() {
        $error = $this->_getParam('error_handler');

        $error_code = 500; // default value: Internal Server Error
        switch ($error->type) {
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
                $error_code = 404; // Not Found
                break;
            default:
                if ($error->exception instanceof Syj_Exception_Request) {
                    $error_code = 400; // Bad Request
                } else if ($error->exception instanceof Syj_Exception_Forbidden) {
                    $error_code = 403; // Forbidden
                } else if ($error->exception instanceof Syj_Exception_NotFound) {
                    $error_code = $error->exception->getCode();
                }
                break;
        }
        $this->httpError($error_code);

        // Log exception, if logger available
        if ($log = $this->getLog()) {
            $log->crit($this->view->message, $error->exception);
        }

        if ($error_code == 400 and $error->request->isXmlHttpRequest()) {
            return $this->_helper->json(array('message' => $error->exception->getMessage()));
        }

        // conditionally display exceptions
{'fraction_non_alphanumeric': 0.12410805300713558, 'fraction_numerical': 0.011213047910295617, 'mean_word_length': 2.3178360101437026, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2878938', 'n_tokens_mistral': 1092, 'n_tokens_neox': 1013, 'n_words': 222}