Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #28 from Elao/fix-error-reporting
Browse files Browse the repository at this point in the history
don't catch error if error_reporting is 0 (when @ is used)'
  • Loading branch information
benji07 committed Dec 18, 2014
2 parents fb06809 + 1540a71 commit 3d40f75
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public function getConfigTreeBuilder()
->booleanNode('handlePHPErrors')
->defaultValue(false)
->end()
->booleanNode('handleSilentErrors')
->defaultValue(false)
->end()
->arrayNode('ignoredClasses')
->prototype('scalar')
->treatNullLike(array())
Expand Down
9 changes: 8 additions & 1 deletion Listener/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Notifier
private $ignoredClasses;
private $reportWarnings = false;
private $reportErrors = false;
private $reportSilent = false;
private $repeatTimeout = false;
private $command;
private $commandInput;
Expand All @@ -66,10 +67,11 @@ public function __construct(Swift_Mailer $mailer, EngineInterface $templating, $
$this->handle404 = $config['handle404'];
$this->reportErrors = $config['handlePHPErrors'];
$this->reportWarnings = $config['handlePHPWarnings'];
$this->reportSilent = $config['handleSilentErrors'];
$this->ignoredClasses = $config['ignoredClasses'];
$this->repeatTimeout = $config['repeatTimeout'];
$this->errorsDir = $cacheDir.'/errors';

if (!is_dir($this->errorsDir)) {
mkdir($this->errorsDir);
}
Expand Down Expand Up @@ -180,6 +182,11 @@ protected function setErrorHandlers()
*/
public function handlePhpError($level, $message, $file, $line, $errcontext)
{
// don't catch error with error_repoting is 0
if (0 === error_reporting() && false === $this->reportSilent) {
return false;
}

// there would be more warning codes but they are not caught by set_error_handler
// but by register_shutdown_function
$warningsCodes = array(E_NOTICE, E_USER_WARNING, E_USER_NOTICE, E_STRICT, E_DEPRECATED, E_USER_DEPRECATED);
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ elao_error_notifier:
mailer: your.mailer.id # default : mailer
handlePHPErrors: true # catch fatal erros and email them
handlePHPWarnings: true # catch warnings and email them
handleSilentErrors: false # don't catch error on method with an @
ignoredClasses: ~
```
Expand Down

0 comments on commit 3d40f75

Please sign in to comment.