1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-09-19 16:38:51 +02:00

Error handling: send Deprecation messages as explicit Event

Summary:
Ref T15554. When a deprecation warning is captured here, mark it as such and send using the same channel as error messages.
Error Handlers will generally ignore it now, so they'll need to be updated, e.g. D25386

Test Plan:
Hitting a `strlen(null)` before This Change:

- Web:
    - PhutilAggregateException - white boxes with red border.
- Daemons:
    - trace in daemon log, task fails. Daemon sleeps for 5 seconds.
- Arcanist and Scripts in phorge/bin/ and phorge/scripts:
    - execution blows up with error trace.
- SSH server-side scripts (ssh-auth and ssh-exec):
    - trace in configured log, execution fails
- SSH client-side scripts (ssh-connect):
    - execution blows up with error trace.

After this change:

- Web:
    - Before `D25386`: Nothing on screen, errors show in log.
    - With `D25386`: logs + dark console.
- Daemons:
    - trace in daemon log, task completes successfully.
- Arcanist and Scripts in phorge/bin/ and phorge/scripts/ :
    - Error trace printed to STDERR, execution continues.
- SSH server-side scripts (ssh-auth and ssh-exec):
    - trace in configured log, execution continues.
- SSH client-side scripts (ssh-connect):
    - Error trace printed to STDERR, execution continues.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15554

Differential Revision: https://we.phorge.it/D25387
This commit is contained in:
Aviv Eyal 2023-08-31 08:12:23 -07:00
parent 8b907d7716
commit d343be5926

View file

@ -203,12 +203,17 @@ final class PhutilErrorHandler extends Phobject {
if (($num === E_USER_ERROR) ||
($num === E_USER_WARNING) ||
($num === E_USER_NOTICE)) {
($num === E_USER_NOTICE) ||
($num === E_DEPRECATED)) {
// See T15554 - we special-case E_DEPRECATED because we don't want them
// to kill the process.
$level = ($num === E_DEPRECATED) ? self::DEPRECATED : self::ERROR;
$trace = debug_backtrace();
array_shift($trace);
self::dispatchErrorMessage(
self::ERROR,
$level,
$str,
array(
'file' => $file,
@ -380,6 +385,7 @@ final class PhutilErrorHandler extends Phobject {
$timestamp = date('Y-m-d H:i:s');
switch ($event) {
case self::DEPRECATED:
case self::ERROR:
$default_message = sprintf(
'[%s] ERROR %d: %s at [%s:%d]',