master

laravel/framework

Last updated at: 29/12/2023 09:21

ExceptionHandler.php

TLDR

This file defines the ExceptionHandler interface in the Illuminate\Contracts\Debug namespace.

Methods

report

This method is responsible for reporting or logging an exception. It takes a Throwable object as a parameter and does not return anything. If an exception is thrown within the method, it will be re-thrown.

shouldReport

This method determines if the exception should be reported. It takes a Throwable object as a parameter and returns a boolean value indicating whether the exception should be reported or not.

render

This method is responsible for rendering an exception into an HTTP response. It takes a \Illuminate\Http\Request object and a Throwable object as parameters, and returns a \Symfony\Component\HttpFoundation\Response object. If an exception is thrown within the method, it will be re-thrown.

renderForConsole

This method is responsible for rendering an exception to the console. It takes an \Symfony\Component\Console\Output\OutputInterface object and a Throwable object as parameters, and does not return anything. This method is intended to be used internally by the framework and should not be modified.

Classes

None

<?php

namespace Illuminate\Contracts\Debug;

use Throwable;

interface ExceptionHandler
{
    /**
     * Report or log an exception.
     *
     * @param  \Throwable  $e
     * @return void
     *
     * @throws \Throwable
     */
    public function report(Throwable $e);

    /**
     * Determine if the exception should be reported.
     *
     * @param  \Throwable  $e
     * @return bool
     */
    public function shouldReport(Throwable $e);

    /**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Throwable  $e
     * @return \Symfony\Component\HttpFoundation\Response
     *
     * @throws \Throwable
     */
    public function render($request, Throwable $e);

    /**
     * Render an exception to the console.
     *
     * @param  \Symfony\Component\Console\Output\OutputInterface  $output
     * @param  \Throwable  $e
     * @return void
     *
     * @internal This method is not meant to be used or overwritten outside the framework.
     */
    public function renderForConsole($output, Throwable $e);
}