Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ExceptionHandler.php « core - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 105caf90582cb8fcee319cf1d4ef57ccca4a4133 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
 * Piwik - Open source web analytics
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 * @category Piwik
 * @package Piwik
 */
use Piwik\Core\Piwik;

/**
 * Exception handler used to display nicely exceptions in Piwik
 *
 * @param Exception $exception
 * @throws Exception
 */
function Piwik_ExceptionHandler(Exception $exception)
{
    try {
        Zend_Registry::get('logger_exception')->logEvent($exception);
    } catch (Exception $e) {

        if (Piwik_FrontController::shouldRethrowException()) {
            throw $exception;
        }

        // case when the exception is raised before the logger being ready
        // we handle the exception a la mano, but using the Logger formatting properties
        $event = array();
        $event['errno'] = $exception->getCode();
        $event['message'] = $exception->getMessage();
        $event['errfile'] = $exception->getFile();
        $event['errline'] = $exception->getLine();
        $event['backtrace'] = $exception->getTraceAsString();

        $formatter = new Piwik_Log_Exception_Formatter_ScreenFormatter();

        $message = $formatter->format($event);
        $message .= "<br /><br />And this exception raised another exception \"" . $e->getMessage() . "\"";

        Piwik::exitWithErrorMessage($message);
    }
}