<commit_before><?php

namespace PragmaRX\Tracker\Support\Exceptions;

use Exception;
use Illuminate\Contracts\Debug\ExceptionHandler;
use PragmaRX\Tracker\Tracker;

class Handler implements ExceptionHandler
{
    private $tracker;

    private $illuminateHandler;

    private $originalExceptionHandler;

    private $originalErrorHandler;

    public function __construct(Tracker $tracker, $illuminateHandler = null)
    {
        $this->tracker = $tracker;

        $this->illuminateHandler = $illuminateHandler;

        $this->initializeHandlers();
    }

    private function initializeHandlers()
    {
        $this->originalExceptionHandler = set_exception_handler([$this, 'handleException']);

        $this->originalErrorHandler = set_error_handler([$this, 'handleError']);
    }

    public function handleException(Exception $exception)
    {
        try {
            $this->tracker->handleException($exception, $exception->getCode());
        } catch (\Exception $e) {
            // Ignore Tracker exceptions
        }

        // Call Laravel Exception Handler
        return call_user_func($this->originalExceptionHandler, $exception);
    }

    public function handleError($err_severity, $err_msg, $err_file, $err_line, array $err_context)
    {
        try {
            $error = ExceptionFactory::make($err_severity, $err_msg);

            $this->tracker->handleException($error, $error->getCode());
        } catch (\Exception $e) {
            // Ignore Tracker exceptions
        }

        // Call Laravel Exception Handler
        return call_user_func($this->originalErrorHandler, $err_severity, $err_msg, $err_file, $err_line);
    }

    public function report(Exception $e)
    {
        try {
            $this->tracker->handleException($e);
        } catch (Exception $exception) {
            // ignore
        }

        $this->illuminateHandler->report($e);
    }

    public function shouldReport(Exception $e)
    {
        return $this->illuminateHandler->shouldReport($e);
    }

    public function render($request, Exception $e)<commit_msg>Laravel 5.8 upgrade change<commit_after><?php

namespace PragmaRX\Tracker\Support\Exceptions;

use Exception;
use Illuminate\Contracts\Debug\ExceptionHandler;
use PragmaRX\Tracker\Tracker;

class Handler implements ExceptionHandler
{
    private $tracker;

    private $illuminateHandler;

    private $originalExceptionHandler;

    private $originalErrorHandler;

    public function __construct(Tracker $tracker, $illuminateHandler = null)
    {
        $this->tracker = $tracker;

        $this->illuminateHandler = $illuminateHandler;

        $this->initializeHandlers();
    }

    private function initializeHandlers()
    {
        $this->originalExceptionHandler = set_exception_handler([$this, 'handleException']);

        $this->originalErrorHandler = set_error_handler([$this, 'handleError']);
    }

    public function handleException(Exception $exception)
    {
        try {
            $this->tracker->handleException($exception, $exception->getCode());
        } catch (\Exception $e) {
            // Ignore Tracker exceptions
        }

        // Call Laravel Exception Handler
        return call_user_func($this->originalExceptionHandler, $exception);
    }

    public function handleError($err_severity, $err_msg, $err_file, $err_line, array $err_context)
    {
        try {
            $error = ExceptionFactory::make($err_severity, $err_msg);

            $this->tracker->handleException($error, $error->getCode());
        } catch (\Exception $e) {
            // Ignore Tracker exceptions
        }

        // Call Laravel Exception Handler
        return call_user_func($this->originalErrorHandler, $err_severity, $err_msg, $err_file, $err_line);
    }

    public function report(Exception $e)
    {
        try {
            $this->tracker->handleException($e);
        } catch (Exception $exception) {
            // ignore
        }

        $this->illuminateHandler->report($e);
    }
    
    public function shouldReport(Exception $e)
    {
        return false;
    }

    public function shouldReport(Exception $e)
    {
        return $this->illuminateHandler->shouldReport($e);
    }

    public function render($request, Exception $e)
{'fraction_non_alphanumeric': 0.1128842994602206, 'fraction_numerical': 0.0004693733865289838, 'mean_word_length': 2.7918149466192173, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, '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': '5275161', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1145, 'n_words': 234}