Final Class Yiisoft\Yii\Console\ErrorListener
| Inheritance | Yiisoft\ |
|---|
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| onError() | Yiisoft\ |
Method Details
| public mixed __construct ( ?\ | ||
| $logger | ?\ |
|
public function __construct(private ?LoggerInterface $logger = null) {}
| public void onError ( \ | ||
| $event | \ |
|
public function onError(ConsoleErrorEvent $event): void
{
if ($this->logger === null) {
return;
}
$exception = $event->getError();
$command = $event->getCommand();
$message = sprintf(
'%s: %s in %s:%s while running console command "%s".',
$exception::class,
$exception->getMessage(),
$exception->getFile(),
$exception->getLine(),
$command?->getName() ?? 'unknown',
);
$this->logger->error($message, ['exception' => $exception]);
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.