<?php


namespace App\Exception;


class ExceptionErrorCatch
{
    public static function register()
    {
        error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
        set_exception_handler([__CLASS__, 'appException']);
        set_error_handler([__CLASS__, 'appError'], E_ALL & ~E_DEPRECATED);
    }

    public static function appException(\Throwable $e)
    {
        $handler = new ExceptionHandler();
        $handler->render($e);
        exit;
    }

    public static function appError($errno, $errstr, $errfile, $errline)
    {
        $handler = new ErrorHandler();
        $handler->render($errno, $errstr, $errfile, $errline);
        exit;
    }
}