master

laravel/framework

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

StreamedResponseException.php

TLDR

This file defines the StreamedResponseException class, which is an exception that can be thrown during the streaming of a response.

Methods

__construct(Throwable $originalException)

This method is the constructor of the StreamedResponseException class. It takes in a Throwable object as a parameter and initializes the originalException property. It also calls the parent constructor with the message from the original exception.

render()

This method renders the exception and returns an empty Illuminate\Http\Response object.

getInnerException()

This method returns the originalException property, which holds the actual exception that was thrown during the stream.

<?php

namespace Illuminate\Routing\Exceptions;

use Illuminate\Http\Response;
use RuntimeException;
use Throwable;

class StreamedResponseException extends RuntimeException
{
    /**
     * The actual exception thrown during the stream.
     *
     * @var \Throwable
     */
    public $originalException;

    /**
     * Create a new exception instance.
     *
     * @param  \Throwable  $originalException
     * @return void
     */
    public function __construct(Throwable $originalException)
    {
        $this->originalException = $originalException;

        parent::__construct($originalException->getMessage());
    }

    /**
     * Render the exception.
     *
     * @return \Illuminate\Http\Response
     */
    public function render()
    {
        return new Response('');
    }

    /**
     * Get the actual exception thrown during the stream.
     *
     * @return \Throwable
     */
    public function getInnerException()
    {
        return $this->originalException;
    }
}