Skip to content

Commit

Permalink
[Debug] generalized ErrorHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Jun 16, 2014
1 parent 4a93d7f commit 839e9ac
Show file tree
Hide file tree
Showing 13 changed files with 799 additions and 228 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@


{% macro display_message(log_index, log) %}
{% if constant('Symfony\\Component\\HttpKernel\\Debug\\ErrorHandler::TYPE_DEPRECATION') == log.context.type|default(0) %}
{% if log.context.level is defined and log.context.type is defined and (constant('E_DEPRECATED') == log.context.type or constant('E_USER_DEPRECATED') == log.context.type) %}
DEPRECATION - {{ log.message }}
{% set id = 'sf-call-stack-' ~ log_index %}
<a href="#" onclick="Sfjs.toggle('{{ id }}', document.getElementById('{{ id }}-on'), document.getElementById('{{ id }}-off')); return false;">
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Debug/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ CHANGELOG
2.6.0
-----

* generalized ErrorHandler and ExceptionHandler,
with some new methods and others deprecated
* enhanced error messages for uncaught exceptions

2.5.0
Expand Down
14 changes: 11 additions & 3 deletions src/Symfony/Component/Debug/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,23 @@ public static function enable($errorReportingLevel = null, $displayErrors = true

static::$enabled = true;

error_reporting(-1);
if (null !== $errorReportingLevel) {
error_reporting($errorReportingLevel);
} else {
error_reporting(-1);
}

ErrorHandler::register($errorReportingLevel, $displayErrors);
if ('cli' !== php_sapi_name()) {
ini_set('display_errors', 0);
ExceptionHandler::register();
// CLI - display errors only if they're not already logged to STDERR
} elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) {
// CLI - display errors only if they're not already logged to STDERR
ini_set('display_errors', 1);
}
$handler = ErrorHandler::register();
if (!$displayErrors) {
$handler->throwAt(0, true);
}

DebugClassLoader::enable();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Debug/DebugClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function getClassLoader()
public static function enable()
{
// Ensures we don't hit https://bugs.php.net/42098
class_exists(__NAMESPACE__.'\ErrorHandler', true);
class_exists('Symfony\Component\Debug\ErrorHandler');

if (!is_array($functions = spl_autoload_functions())) {
return;
Expand Down
Loading

0 comments on commit 839e9ac

Please sign in to comment.