PHP code example of webservco / exception

1. Go to this page and download the library: Download webservco/exception 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/ */

    

webservco / exception example snippets


use WebServCo\Exception\Factory\DefaultExceptionHandlerFactory;

$exceptionHandlerFactory = new DefaultExceptionHandlerFactory();
// $logger: \Psr\Log\LoggerInterface
set_exception_handler([$exceptionHandlerFactory->createUncaughtExceptionHandler($logger), 'handle']);

// \WebServCo\Exception\Contract\ExceptionHandlerInterface
$exceptionHandler = $exceptionHandlerFactory->createExceptionHandler($logger);

try {
    $service->doSomething();
} catch (Throwable $throwable) {
    $exceptionHandler->handle($throwable);
}