<commit_before><?php

namespace Boom\Exception\Handler;

use Kohana;
use Kohana_Exception;
use HTTP_Exception;
use Exception;
use Boom\Log\ErrorLogger;

abstract class Handler
{
    /**
	 * HTTP response code for this type of exception
	 *
	 * @var int
	 */
    protected $code;

    /**
	 *
	 * @var Exception
	 */
    protected $e;

    /**
     *
     * @var ErrorLogger
     */
    private $errorLogger;

    public function __construct(Exception $e)
    {
        $this->e = $e;
        $this->code = ($e instanceof HTTP_Exception) ? $e->getCode() : 500;
        $this->errorLogger = new ErrorLogger();
    }

    public function execute()
    {
        if (! $this->e instanceof HTTP_Exception) {
            $this->errorLogger->critical(Kohana_Exception::text($this->e));
        }
    }

    public static function handle(Exception $e)
    {
        try {
            $handler_class = (Kohana::$environment === Kohana::PRODUCTION || Kohana::$environment === Kohana::STAGING) ? 'Priv' : 'Pub';
            $class = "\\Boom\\Exception\\Handler\\$handler_class";
            $handler = new $class($e);

            $handler->execute();
        } catch (Exception $e) {
            Kohana_Exception::handler($e);
        }
    }

    public static function setExceptionHandler()
    {
        set_exception_handler(['\\Boom\\Exception\\Handler\\Handler', 'handle']);
    }
}<commit_msg>Updated Exception\Handler\Handler::handle() to use Environment->getExceptionHandler() instead of Kohana::$environment<commit_after><?php

namespace Boom\Exception\Handler;

use Kohana_Exception;
use HTTP_Exception;
use Exception;
use Boom\Log\ErrorLogger;
use Boom\Boom;

abstract class Handler
{
    /**
	 * HTTP response code for this type of exception
	 *
	 * @var int
	 */
    protected $code;

    /**
	 *
	 * @var Exception
	 */
    protected $e;

    /**
     *
     * @var ErrorLogger
     */
    private $errorLogger;

    public function __construct(Exception $e)
    {
        $this->e = $e;
        $this->code = ($e instanceof HTTP_Exception) ? $e->getCode() : 500;
        $this->errorLogger = new ErrorLogger();
    }

    public function execute()
    {
        if (! $this->e instanceof HTTP_Exception) {
            $this->errorLogger->critical(Kohana_Exception::text($this->e));
        }
    }

    public static function handle(Exception $e)
    {
        try {
            $handler = Boom::instance()->getEnvironment()->getExceptionHandler($e);
            $handler->execute();
        } catch (Exception $e) {
            Kohana_Exception::handler($e);
        }
    }

    public static function setExceptionHandler()
    {
        set_exception_handler(['\\Boom\\Exception\\Handler\\Handler', 'handle']);
    }
}
{'fraction_non_alphanumeric': 0.14228089475614228, 'fraction_numerical': 0.0022002200220022, 'mean_word_length': 2.3930348258706466, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, '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': '3858444', 'n_tokens_mistral': 826, 'n_tokens_neox': 783, 'n_words': 173}