PHP code example of xervice / exception-handler

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

    

xervice / exception-handler example snippets




namespace App\ExceptionHandler;

use Xervice\ExceptionHandler\ExceptionHandlerDependencyProvider as XerviceExceptionHandlerDependencyProvider;

class ExceptionHandlerDependencyProvider extends XerviceExceptionHandlerDependencyProvider
{
    /**
     * @return \Xervice\ExceptionHandler\Business\Model\Register\RegisterInterface[]
     */
    public function getExceptionRegister(): array
    {
        return [
            new MyExceptionRegister() // implements RegisterInterface
        ];
    }
}



namespace App\ExceptionHandler;

use Xervice\ExceptionHandler\ExceptionHandlerDependencyProvider as XerviceExceptionHandlerDependencyProvider;

class ExceptionHandlerDependencyProvider extends XerviceExceptionHandlerDependencyProvider
{
    /**
     * @return \Xervice\ExceptionHandler\Business\Model\Handler\ExceptionHandlerInterface[]
     */
    public function getExceptionHandler(): array
    {
        return [
            new MyExceptionHandler() // implements ExceptionHandlerInterface
        ];
    }
}

$exceptionHandlerFacade->handleException($exception);

This will loop all defined ExceptionHandler with the given exception.