diff --git a/src/rollbar.php b/src/rollbar.php index 2fad63e2..a54476e2 100644 --- a/src/rollbar.php +++ b/src/rollbar.php @@ -79,20 +79,12 @@ public static function flush() { } class RollbarException { - private $level; private $message; - private $err; - private $custom; + private $exception; - public function __construct($level, $message, Exception $err = null, $custom = null) { - $this->level = $level; + public function __construct( $message, Exception $exception = null) { $this->message = $message; - $this->err = $err; - $this->custom = $custom; - } - - public function getLevel() { - return $this->level; + $this->exception = $exception; } public function getMessage() { @@ -100,11 +92,7 @@ public function getMessage() { } public function getException() { - return $this->err; - } - - public function getCustom() { - return $this->custom; + return $this->exception; } } @@ -271,15 +259,15 @@ public function queueSize() { * Run the checkIgnore function and determine whether to send the Exception to the API or not. * * @param bool $isUncaught - * @param RollbarException $caller_args [level, message, err, custom] - * @param array $payload Data being sent to the API + * @param RollbarException $exception + * @param array $payload Data being sent to the API * @return bool */ - protected function _shouldIgnore($isUncaught, RollbarException $caller_args, array $payload) + protected function _shouldIgnore($isUncaught, RollbarException $exception, array $payload) { try { if (is_callable($this->checkIgnore) - && call_user_func_array($this->checkIgnore, array($isUncaught,$caller_args,$payload)) + && call_user_func_array($this->checkIgnore, array($isUncaught,$exception,$payload)) ) { $this->log_info('This item was not sent to Rollbar because it was ignored. ' . 'This can happen if a custom checkIgnore() function was used.'); @@ -338,7 +326,7 @@ protected function _report_exception(Exception $exc, $extra_data = null, $payloa $payload = $this->build_payload($data); // Determine whether to send the request to the API. - if ($this->_shouldIgnore(true, new RollbarException($data['level'], $exc->getMessage(), $exc), $payload)) { + if ($this->_shouldIgnore(true, new RollbarException($exc->getMessage(), $exc), $payload)) { return; } @@ -476,7 +464,8 @@ protected function _report_php_error($errno, $errstr, $errfile, $errline) { $payload = $this->build_payload($data); // Determine whether to send the request to the API. - if ($this->_shouldIgnore(true, new RollbarException($level, $errstr), $payload)) { + $exception = new ErrorException($error_class, 0, $errno, $errfile, $errline); + if ($this->_shouldIgnore(true, new RollbarException($exception->getMessage(), $exception), $payload)) { return; } @@ -523,7 +512,7 @@ protected function _report_message($message, $level, $extra_data, $payload_data) $payload = $this->build_payload($data); // Determine whether to send the request to the API. - if ($this->_shouldIgnore(true, new RollbarException($level, $message), $payload)) { + if ($this->_shouldIgnore(true, new RollbarException($message), $payload)) { return; }