Changeset View
Changeset View
Standalone View
Standalone View
src/error/PhutilErrorHandler.php
Context not available. | |||||
} | } | ||||
// Convert typehint failures into exceptions. | // Convert typehint failures into exceptions. | ||||
if (preg_match('/^Argument (\d+) passed to (\S+) must be/', $str)) { | if (@preg_match('/^Argument (\d+) passed to (\S+) must be/', $str)) { | ||||
throw new InvalidArgumentException($str); | throw new InvalidArgumentException($str); | ||||
} | } | ||||
Context not available. | |||||
} | } | ||||
// Convert uses of undefined variables into exceptions. | // Convert uses of undefined variables into exceptions. | ||||
if (preg_match('/^Undefined variable: /', $str)) { | if (@preg_match('/^Undefined variable: /', $str)) { | ||||
throw new RuntimeException($str); | throw new RuntimeException($str); | ||||
} | } | ||||
// Convert uses of undefined properties into exceptions. | // Convert uses of undefined properties into exceptions. | ||||
if (preg_match('/^Undefined property: /', $str)) { | if (@preg_match('/^Undefined property: /', $str)) { | ||||
throw new RuntimeException($str); | throw new RuntimeException($str); | ||||
} | } | ||||
// Convert undefined constants into exceptions. Usually this means there | // Convert undefined constants into exceptions. Usually this means there | ||||
// is a missing `$` and the program is horribly broken. | // is a missing `$` and the program is horribly broken. | ||||
if (preg_match('/^Use of undefined constant /', $str)) { | if (@preg_match('/^Use of undefined constant /', $str)) { | ||||
throw new RuntimeException($str); | throw new RuntimeException($str); | ||||
} | } | ||||
// Convert undefined indexes into exceptions. | // Convert undefined indexes into exceptions. | ||||
if (preg_match('/^Undefined index: /', $str)) { | if (@preg_match('/^Undefined index: /', $str)) { | ||||
throw new RuntimeException($str); | throw new RuntimeException($str); | ||||
} | } | ||||
// Convert undefined offsets into exceptions. | // Convert undefined offsets into exceptions. | ||||
if (preg_match('/^Undefined offset: /', $str)) { | if (@preg_match('/^Undefined offset: /', $str)) { | ||||
throw new RuntimeException($str); | throw new RuntimeException($str); | ||||
} | } | ||||
Context not available. | |||||
* @task internal | * @task internal | ||||
*/ | */ | ||||
public static function outputStacktrace($trace) { | public static function outputStacktrace($trace) { | ||||
$lines = explode("\n", self::formatStacktrace($trace)); | $lines = @explode("\n", self::formatStacktrace($trace)); | ||||
foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
error_log($line); | error_log($line); | ||||
} | } | ||||
Context not available. | |||||
* @task internal | * @task internal | ||||
*/ | */ | ||||
public static function dispatchErrorMessage($event, $value, $metadata) { | public static function dispatchErrorMessage($event, $value, $metadata) { | ||||
$timestamp = strftime('%Y-%m-%d %H:%M:%S'); | $timestamp = @strftime('%Y-%m-%d %H:%M:%S'); | ||||
switch ($event) { | switch ($event) { | ||||
case self::ERROR: | case self::ERROR: | ||||
Context not available. | |||||
} while ($current = self::getPreviousException($current)); | } while ($current = self::getPreviousException($current)); | ||||
$messages = implode(' {>} ', $messages); | $messages = implode(' {>} ', $messages); | ||||
if (strlen($messages) > 4096) { | if (@strlen($messages) > 4096) { | ||||
$messages = substr($messages, 0, 4096).'...'; | $messages = @substr($messages, 0, 4096).'...'; | ||||
} | } | ||||
$default_message = sprintf( | $default_message = sprintf( | ||||
Context not available. | |||||
break; | break; | ||||
} | } | ||||
if (!strncmp($root, $path, strlen($root))) { | if (!strncmp($root, $path, @strlen($root))) { | ||||
return '<'.$library.'>'.substr($path, strlen($root)); | return '<'.$library.'>'.@substr($path, @strlen($root)); | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
if (@file_exists($try_file)) { | if (@file_exists($try_file)) { | ||||
$head = @file_get_contents($try_file); | $head = @file_get_contents($try_file); | ||||
$matches = null; | $matches = null; | ||||
if (preg_match('(^ref: refs/heads/(.*)$)', trim($head), $matches)) { | if (@preg_match('(^ref: refs/heads/(.*)$)', trim($head), $matches)) { | ||||
$libinfo[$library]['head'] = trim($matches[1]); | $libinfo[$library]['head'] = trim($matches[1]); | ||||
$get_refs[] = trim($matches[1]); | $get_refs[] = trim($matches[1]); | ||||
} else { | } else { | ||||
Context not available. | |||||
if (@file_exists($try_file)) { | if (@file_exists($try_file)) { | ||||
$hash = @file_get_contents($try_file); | $hash = @file_get_contents($try_file); | ||||
if ($hash) { | if ($hash) { | ||||
$libinfo[$library]['ref.'.$ref] = substr(trim($hash), 0, 12); | $libinfo[$library]['ref.'.$ref] = @substr(trim($hash), 0, 12); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
Context not available. | |||||
if ($custom) { | if ($custom) { | ||||
$count = 0; | $count = 0; | ||||
foreach ($custom as $custom_path) { | foreach ($custom as $custom_path) { | ||||
if (preg_match('/\.php$/', $custom_path)) { | if (@preg_match('/\.php$/', $custom_path)) { | ||||
$count++; | $count++; | ||||
} | } | ||||
} | } | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0