squareboat / sneaker

An easy way to send emails whenever an exception occurs on server.
MIT License
222 stars 46 forks source link

Possible to have a list of what NOT to capture? #36

Closed ataylor32 closed 5 years ago

ataylor32 commented 5 years ago

Like issue #24, I'd like to capture everything with some exceptions:

Looking at the Sneaker class' shouldCapture method, this doesn't appear to be possible right now. Would you be willing and able to add this functionality?

akaamitgupta commented 5 years ago

@ataylor32 You can just check the type of exception before calling app('sneaker')->captureException($exception) in your code and it will solve your problem.

ataylor32 commented 5 years ago

@akaamitgupta Thank you. I don't have a lot of Laravel experience. I saw your comment on #24, but didn't know what $this->shouldReport($exception) was referring to. I see now that it's from Illuminate\Foundation\Exceptions\Handler, which is what App\Exceptions\Handler extends. So I changed the report method from this:

app('sneaker')->captureException($exception);

...to this:

if ($this->shouldReport($exception)) {
    app('sneaker')->captureException($exception);
}

I also have Sneaker's capture array set to '*'. That solved it. Thanks again!