PHP Classes
elePHPant
Icontem

Exceptionizer Bundle: Throw exceptions that can be caught with listeners

Recommend this page to a friend!
  Info   View files Documentation   View files View files (19)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2015-07-06 (1 year ago) RSS 2.0 feedNot enough user ratingsTotal: 101 All time: 8,461 This week: 935Up
Version License PHP version Categories
exceptionizer-bundle 1.0MIT/X Consortium ...5.3.9PHP 5, Language
Description Author

This package can throw exceptions that can be caught with listeners.

It can register Symfony observers that can listen to events and can be called before throwing an exception or after the exception is caught.

The exceptions may be thrown by name with parameters or read from configuration file in YAML format.

Picture of Mohamed Aymen Ben Slimane
  Performance   Level  
Name: Mohamed Aymen Ben ... <contact>
Classes: 2 packages by
Country: Tunisia Tunisia

Details

exceptionizer-bundle SensioLabsInsight

Build Status Scrutinizer Code Quality

Play with Exceptions :D This bundle help to get a low coupling between exception class object in your code

Installation

Exceptionizer uses Composer, please checkout the composer website for more information.

The simple following command will install exceptionizer-bundle into your project. It also add a new entry in your composer.json and update the composer.lock as well.

$ composer require 'mabs/exceptionizer-bundle'

Then, you can enable it in your kernel:

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        ...
        new Mabs\ExceptionizerBundle\MabsExceptionizerBundle(),
        ...

Usage

Now you can use Exceptionizer service to throw Exceptions:

$this->container->get('exceptionizer')
->throwException('\\Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException', array('Your message'));

OR define your Exception in your config.yml file like this :

mabs_exceptionizer:
    exceptions:
        bar_code_exception:
            class: Mabs\BarCodeBundle\Exception\BarCodeException
            arguments:                          # optional
                message: "bar code exception"   # optional
                code:  0                        # optional

and pass the config key to the service:

$this->container->get('exceptionizer')->throwException('bar_code_exception');

Events and listener:

ExceptionizerBundle provide two events:

namespace Mabs\ExceptionizerBundle;


final class ExceptionizerEvents
{

    const EXCEPTIONIZER_PRE_THROW = 'exceptionizer.pre_throw';

    const EXCEPTIONIZER_POST_CATCH = 'exceptionizer.post_catch';
}

<b>exceptionizer.pre_throw</b> : before throw Exception

<b>exceptionizer.post_catch</b>: (will be documented later when we speak about the Exception Catcher)

Now you can create Listeners to do a specific job when an exception will be thrown ;) and to learn more about the EventDispatcher Component in symfony2 pleaze read the documentation

License

This bundle is available under the MIT license.

  Files folder image Files  
File Role Description
Files folder imageDependencyInjection (2 files)
Files folder imageEvent (1 file)
Files folder imageEventListener (1 file)
Files folder imageException (1 file)
Files folder imageExceptionizer (2 files, 1 directory)
Files folder imageResources (1 directory)
Files folder imageService (1 file)
Files folder imageTests (1 directory)
Accessible without login Plain text file .scrutinizer.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Plain text file ExceptionizerEvents.php Class Class source
Accessible without login Plain text file LICENSE Lic. Auxiliary data
Plain text file MabsExceptionizerBundle.php Class Class source
Accessible without login Plain text file README.md Doc. Auxiliary data

  Files folder image Files  /  DependencyInjection  
File Role Description
  Plain text file Configuration.php Class Class source
  Plain text file MabsExceptionizerExtension.php Class Class source

  Files folder image Files  /  Event  
File Role Description
  Plain text file FilterExceptionizerEvent.php Class Class source

  Files folder image Files  /  EventListener  
File Role Description
  Plain text file MabsExceptionizerListener.php Class Class source

  Files folder image Files  /  Exception  
File Role Description
  Plain text file BaseException.php Class Class source

  Files folder image Files  /  Exceptionizer  
File Role Description
Files folder imageCommon (2 files)
  Plain text file Catcher.php Class Class source
  Plain text file Thrower.php Class Class source

  Files folder image Files  /  Exceptionizer  /  Common  
File Role Description
  Plain text file CatcherInterface.php Class Class source
  Plain text file ThrowerInterface.php Class Class source

  Files folder image Files  /  Resources  
File Role Description
Files folder imageconfig (2 files)

  Files folder image Files  /  Resources  /  config  
File Role Description
  Accessible without login Plain text file config.yml Data Auxiliary data
  Accessible without login Plain text file services.xml Data Auxiliary data

  Files folder image Files  /  Service  
File Role Description
  Plain text file Exceptionizer.php Class Class source

  Files folder image Files  /  Tests  
File Role Description
Files folder imageController (1 file)

  Files folder image Files  /  Tests  /  Controller  
File Role Description
  Accessible without login Plain text file DefaultControllerTest.php Test Unit test script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:101
This week:0
All time:8,461
This week:935Up