PHP code example of idiosyncratic / http-exceptions

1. Go to this page and download the library: Download idiosyncratic/http-exceptions library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

idiosyncratic / http-exceptions example snippets


use Idiosyncratic\Http\Exception\Server\InternalServerError;

// $request must be an instance of Psr\Http\Message\ServerRequestInterface;
throw new InternalServerError($request);

use Idiosyncratic\Http\Exception\Server\InternalServerError;


try {
    throw new \Exception('Something went wrong');
} catch (\Throwable $throwable) {
    // $request must be an instance of Psr\Http\Message\ServerRequestInterface;
    throw new InternalServerError($request, $throwable);
}