Skip to content
This repository has been archived by the owner on Oct 25, 2021. It is now read-only.

Latest commit

 

History

History
75 lines (41 loc) · 2.02 KB

event-stream.rst

File metadata and controls

75 lines (41 loc) · 2.02 KB

FaultManagerdoc

Event Stream

That is the most powerful feature of Fault Manager, the ability to provide Exceptions that would be added into Event Stream and attach handler for all Exceptions or additionally to specific exceptions.

Enabling Event Stream

In order to enable Event Stream you simply need to type the following command:

php

Fault::enableEventStream();

You can check if Event Stream is enabled with

php

Fault::isEventStreamEnabled();

If you want to disable Event Stream you can use

php

Fault::disableEventStream();

Note

When Event Stream is Enabled, custom generated exceptions will not extend from PHP built-in :php\Exception class, instead, will extend the :php\\Omega\\FaultManager\\Abstracts\\FaultManagerException abstract class

Warning

In order to use Event Stream everywhere in your app, make sure that you call :phpFault::enableEventStream() method before calling :phpFault::throw() / :phpFault::exception() methods.

Generate Evented Custom Exception

Once the Event Stream is enabled then the process of generating an evented custom exception is the same as with normal custom exceptions shown in "generate-custom-exception" example.

So since we already have enabled Event Stream in our app, then once we run the following code:

php

Fault::throw('CustomException', 'a message here');

A file CustomException.php will be generated (in case it does not already exist) with the following contents:

<?php

class CustomException extends \Omega\FaultManager\Abstracts\FaultManagerException
{


}

Now you are all set! Time to move to features.event-handler !