-
Notifications
You must be signed in to change notification settings - Fork 120
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
Conversation
👍 |
{ | ||
try { | ||
if (is_callable($this->checkIgnore) | ||
&& call_user_func_array($this->checkIgnore, array($isUncaught,$caller_args,$payload)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. So RollbarException
seems to be duplicating a lot of stuff that's already present in $payload
. Is there a notable difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I literally just copied the functionality and tried to ensure it was consistent with the JS version. I agree it doesn't really make sense; I wasn't sure how to handle the two cases where there is not an exception:
- Logging a message
- Logging a PHP error
On a more general level, would this function allows users to tweak the payload before it gets sent? It's not necessarily a bad thing, but mutating can have annoying side effects. Is there an easy, fast deep clone mechanism in PHP? That could make this 'pure' (apart from its arguments) by passing a cloned version of the Note: this is why there's a separate |
At the moment they can't tweak the payload no. |
@bytestream what prevents them from tweaking it? Couldn't I just say |
@Crisfole PHP passes function args by value not by reference :) http://php.net/manual/en/functions.arguments.php |
Right, but the 'value' of most object types (arrays and maps included) in most languages is simply the reference to the object. Does PHP not work this way? |
@Crisfole only for objects, otherwise you have to explicitly say you want to use them by reference with |
👍 I'd say this is close to good to go once we make sure that the |
@Crisfole done ^ |
@@ -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); |
There was a problem hiding this comment.
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.
K, last thought is that we probably don't need the If people want to call It might be nice to have a third parameter for Thoguhts? |
You can differentiate between a message and an exception by just checking if public function ignore($isUncaught, RollbarException $exception, $payload)
{
if (is_null($exception)) {
// we have a message
} else {
if ($exception instanceof ErrorException) {
// we have a php error
} else {
// we have a normal error
}
}
} The OO way is more long winded, arguably nicer, but would be this (untested): interface RollbarException {
public function getMessage();
}
class RollbarPhpError extends ErrorException implements RollbarException
{
//
}
class RollbarMessage implements RollbarException
{
public function getMessage()
{
//
}
}
class RollbarUncaughtException extends Exception implements RollbarException
{
//
}
public function ignore($isUncaught, RollbarException $exception, $payload)
{
if ($exception instanceof RollbarPhpError) {
//
} elseif ($exception instanceof RollbarMessage) {
//
} elseif ($exception instanceof RollbarUncaughtException) {
//
} else {
// getMessage()
}
} |
I think I'm good with it the way it is, then. @brianr what do you think? @bytestream Once we get a second pair of eyes on this we can merge and up the version number. |
Looks good to me, merging in. |
Copied over the checkIgnore functionality from https://github.com/rollbar/rollbar.js/blob/a072cb78a9056ebded63879e6eec473d6ff1752d/release/rollbar-1.8.5.js