-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #622 from bugsnag/discard-classes
Add ability to discard events based on class/error names
- Loading branch information
Showing
10 changed files
with
507 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Bugsnag\Middleware; | ||
|
||
use Bugsnag\Configuration; | ||
use Bugsnag\Report; | ||
|
||
class DiscardClasses | ||
{ | ||
/** | ||
* @var \Bugsnag\Configuration | ||
*/ | ||
protected $config; | ||
|
||
/** | ||
* @param \Bugsnag\Configuration $config | ||
*/ | ||
public function __construct(Configuration $config) | ||
{ | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* @param \Bugsnag\Report $report | ||
* @param callable $next | ||
* | ||
* @return void | ||
*/ | ||
public function __invoke(Report $report, callable $next) | ||
{ | ||
$errors = $report->getErrors(); | ||
|
||
foreach ($this->config->getDiscardClasses() as $discardClass) { | ||
foreach ($errors as $error) { | ||
if ($error['errorClass'] === $discardClass | ||
|| @preg_match($discardClass, $error['errorClass']) === 1 | ||
) { | ||
syslog(LOG_INFO, sprintf( | ||
'Discarding event because error class "%s" matched discardClasses configuration', | ||
$error['errorClass'] | ||
)); | ||
|
||
return; | ||
} | ||
} | ||
} | ||
|
||
$next($report); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace Bugsnag\Tests\Fakes; | ||
|
||
use Exception; | ||
|
||
final class SomeException extends Exception | ||
{ | ||
} |
Oops, something went wrong.