Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added checkIgnore config option. (#45) #82

Merged
merged 4 commits into from
May 25, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 12 additions & 23 deletions src/rollbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,32 +79,20 @@ 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() {
return $this->message;
}

public function getException() {
return $this->err;
}

public function getCustom() {
return $this->custom;
return $this->exception;
}
}

Expand Down Expand Up @@ -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.');
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 That's great! I didn't know ErrorException existed. That's a nice solution.

if ($this->_shouldIgnore(true, new RollbarException($exception->getMessage(), $exception), $payload)) {
return;
}

Expand Down Expand Up @@ -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;
}

Expand Down