Console::run() calls $command->run() with no try/catch (src/Console.php:284-304), so any exception escaping a command reaches PHP's default handler. The user gets a raw fatal error and a stack trace on STDOUT, with display_errors deciding how much of it, and the exit code is 255 rather than something meaningful.
For a console library this is the one place where a friendly failure matters most, and everything needed is already here: CLI::error() for the STDERR path, and CLI::isQuiet() / an IS_DEV style flag to decide whether to show the trace.
Suggested behaviour:
- Catch
Throwable around the command dispatch.
- Print
message in red on STDERR, plus the class name and the trace when the console is in a debug mode.
- Exit with a non zero code (1, or the exception code when it is in range).
- Leave a hook so an application can register its own handler, since a framework will usually want to log it as well.
Console::run()calls$command->run()with notry/catch(src/Console.php:284-304), so any exception escaping a command reaches PHP's default handler. The user gets a raw fatal error and a stack trace on STDOUT, withdisplay_errorsdeciding how much of it, and the exit code is 255 rather than something meaningful.For a console library this is the one place where a friendly failure matters most, and everything needed is already here:
CLI::error()for the STDERR path, andCLI::isQuiet()/ anIS_DEVstyle flag to decide whether to show the trace.Suggested behaviour:
Throwablearound the command dispatch.messagein red on STDERR, plus the class name and the trace when the console is in a debug mode.