|
6 | 6 | use Exception;
|
7 | 7 | use Illuminate\Auth\Access\AuthorizationException;
|
8 | 8 | use Illuminate\Auth\AuthenticationException;
|
| 9 | +use Illuminate\Console\View\Components\BulletList; |
| 10 | +use Illuminate\Console\View\Components\Error; |
9 | 11 | use Illuminate\Contracts\Container\Container;
|
10 | 12 | use Illuminate\Contracts\Debug\ExceptionHandler as ExceptionHandlerContract;
|
11 | 13 | use Illuminate\Contracts\Foundation\ExceptionRenderer;
|
|
30 | 32 | use Psr\Log\LoggerInterface;
|
31 | 33 | use Psr\Log\LogLevel;
|
32 | 34 | use Symfony\Component\Console\Application as ConsoleApplication;
|
| 35 | +use Symfony\Component\Console\Exception\CommandNotFoundException; |
33 | 36 | use Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer;
|
34 | 37 | use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
|
35 | 38 | use Symfony\Component\HttpFoundation\RedirectResponse as SymfonyRedirectResponse;
|
@@ -718,6 +721,23 @@ protected function convertExceptionToArray(Throwable $e)
|
718 | 721 | */
|
719 | 722 | public function renderForConsole($output, Throwable $e)
|
720 | 723 | {
|
| 724 | + if ($e instanceof CommandNotFoundException) { |
| 725 | + $message = str($e->getMessage())->explode('.')->first(); |
| 726 | + |
| 727 | + if (! empty($alternatives = $e->getAlternatives())) { |
| 728 | + $message .= '. Did you mean one of these?'; |
| 729 | + |
| 730 | + with(new Error($output))->render($message); |
| 731 | + with(new BulletList($output))->render($e->getAlternatives()); |
| 732 | + |
| 733 | + $output->writeln(''); |
| 734 | + } else { |
| 735 | + with(new Error($output))->render($message); |
| 736 | + } |
| 737 | + |
| 738 | + return; |
| 739 | + } |
| 740 | + |
721 | 741 | (new ConsoleApplication)->renderThrowable($e, $output);
|
722 | 742 | }
|
723 | 743 |
|
|
0 commit comments