/**
  * @dataProvider getLevels
  */
 public function testThrowException($level, $type)
 {
     try {
         ErrorException::throwException($level, '{whot}', '{file}', '13');
     } catch (ErrorException $e) {
         $this->assertContains('PHP ' . $type, $e->getMessage());
         $this->assertContains('{whot}', $e->getMessage());
         $this->assertContains('in {file}', $e->getMessage());
         $this->assertContains('on line 13', $e->getMessage());
     }
 }
 /**
  * Helper for throwing an ErrorException.
  *
  * This allows us to:
  *
  *     set_error_handler(array($psysh, 'handleError'));
  *
  * Unlike ErrorException::throwException, this error handler respects the
  * current error_reporting level; i.e. it logs warnings and notices, but
  * doesn't throw an exception unless it's above the current error_reporting
  * threshold. This should probably only be used in the inner execution loop
  * of the shell, as most of the time a thrown exception is much more useful.
  *
  * @see \Psy\Exception\ErrorException::throwException
  * @see \Psy\Shell::writeException
  *
  * @param int    $errno   Error type
  * @param string $errstr  Message
  * @param string $errfile Filename
  * @param int    $errline Line number
  */
 public function handleError($errno, $errstr, $errfile, $errline)
 {
     if ($errno & error_reporting()) {
         ErrorException::throwException($errno, $errstr, $errfile, $errline);
     } else {
         // log it and continue...
         $this->writeException(new ErrorException($errstr, 0, $errno, $errfile, $errline));
     }
 }