예제 #1
0
 /**
  * @dataProvider provider_project_root
  */
 public function test_project_root_should_shorten_file_paths($project_root, $shortened, $full)
 {
     Honeybadger::$config = new Config(array('project_root' => $project_root));
     $actual = Filter::project_root(array('file' => $full));
     $this->assertEquals($shortened, $actual['file']);
     Honeybadger::$config = new Config();
 }
예제 #2
0
 public static function handle($code, $error, $file = NULL, $line = NULL)
 {
     if (error_reporting() & $code) {
         // This error is not suppressed by current error reporting settings.
         // Convert the error into an ErrorException.
         $exception = new \ErrorException($error, $code, 0, $file, $line);
         // Send the error to Honeybadger.
         Honeybadger::notify_or_ignore($exception);
     }
     if (is_callable(self::$previous_handler)) {
         // Pass the triggered error on to the previous error handler.
         return call_user_func(self::$previous_handler, $code, $error, $file, $line);
     }
     // Execute the PHP error handler.
     return FALSE;
 }
예제 #3
0
 public static function handle(\Exception $e)
 {
     try {
         // Attempt to send this exception to Honeybadger.
         Honeybadger::notify_or_ignore($e);
     } catch (Exception $e) {
         if (is_callable(self::$previous_handler)) {
             return call_user_func(self::$previous_handler, $e);
         } else {
             // Clean the output buffer if one exists.
             ob_get_level() and ob_clean();
             // Set the Status code to 500, and Content-Type to text/plain.
             header('Content-Type: text/plain; charset=utf-8', TRUE, 500);
             echo 'Someting went terribly wrong.';
             // Exit with a non-zero status.
             exit(1);
         }
     }
     if (is_callable(self::$previous_handler)) {
         return call_user_func(self::$previous_handler, $e);
     }
 }
예제 #4
0
 public function test_notify_or_ignore_does_not_notify_when_ignored()
 {
     Honeybadger::$config->ignore = array('Exception');
     $this->assertEmpty(Honeybadger::notify_or_ignore($this->build_exception()));
 }