run() public static method

This method (ErrorHandler::run()) needs to be called as early as possible in the bootstrap cycle; immediately after require-ing bootstrap/libraries.php is your best bet.
public static run ( array $config = [] )
$config array The configuration with which to start the error handler. Available options include: - `'trapErrors'` _boolean_: Defaults to `false`. If set to `true`, PHP errors will be caught by `ErrorHandler` and handled in-place. Execution will resume in the same context in which the error occurred. - `'convertErrors'` _boolean_: Defaults to `true`, and specifies that all PHP errors should be converted to `ErrorException`s and thrown from the point where the error occurred. The exception will be caught at the first point in the stack trace inside a matching `try`/`catch` block, or that has a matching error handler applied using the `apply()` method.
Beispiel #1
0
 public function setUp()
 {
     if (!ErrorHandler::isRunning()) {
         ErrorHandler::run();
     }
     ErrorHandler::reset();
     $this->errors = array();
 }
 public function testErrorTrapping()
 {
     ErrorHandler::stop();
     $self = $this;
     ErrorHandler::config(array(array('handler' => function ($info) use($self) {
         $self->errors[] = $info;
     })));
     ErrorHandler::run(array('trapErrors' => true));
     $this->assertEqual(0, count($this->errors));
     list($foo, $bar) = array('baz');
     $this->assertEqual(1, count($this->errors));
 }
Beispiel #3
0
 public function testErrorTrapping()
 {
     ErrorHandler::stop();
     ErrorHandler::run(array('trapErrors' => true));
     // Undefined offset error shouldn't surface.
     list($foo, $bar) = array('baz');
 }