Skip to content

xervice/exception-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ExceptionHandler

Build Status Scrutinizer Code Quality Code Coverage

Installation

composer require xervice/exception-handler

Configuration

You have to add the ExceptionService to your kernel stack.

After that the defined registers will be executed. To define a register you have to overwrite the DependencyProvider:

<?php

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
        ];
    }
}

You can define the default "ExceptionHandlerRegister". If you use it, you can define own ExceptionHandler. Every ExceptionHandler get automatically exexpected exceptions. You can define your ExceptionHandler also in the Dependency Provider.

<?php

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
        ];
    }
}

Usage

Also you can parse your own exception by using the Facade:

$exceptionHandlerFacade->handleException($exception);

This will loop all defined ExceptionHandler with the given exception.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages