-
Notifications
You must be signed in to change notification settings - Fork 544
Let exceptions fly while bootstrapping #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
854f2b2
Let exceptions fly while bootstrapping
clxmstaab f68f38c
Adding the exception-cause to bootstrapping errors
clxmstaab 252c458
Revert "Let exceptions fly while bootstrapping"
clxmstaab eb02a32
Revert "Adding the exception-cause to bootstrapping errors"
clxmstaab baa885c
use Symfony\Component\Console\Application::renderException()
clxmstaab 84e8154
fix missing arg
clxmstaab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| use PHPStan\DependencyInjection\NeonAdapter; | ||
| use PHPStan\File\FileFinder; | ||
| use PHPStan\File\FileHelper; | ||
| use Symfony\Component\Console\Application; | ||
| use Symfony\Component\Console\Input\InputInterface; | ||
| use Symfony\Component\Console\Output\ConsoleOutputInterface; | ||
| use Symfony\Component\Console\Output\OutputInterface; | ||
|
|
@@ -36,7 +37,8 @@ public static function begin( | |
| ?string $autoloadFile, | ||
| ?string $projectConfigFile, | ||
| ?string $level, | ||
| bool $allowXdebug | ||
| bool $allowXdebug, | ||
| Application $application | ||
| ): InceptionResult | ||
| { | ||
| if (!$allowXdebug) { | ||
|
|
@@ -129,7 +131,7 @@ public static function begin( | |
| try { | ||
| $projectConfig = $loader->load($projectConfigFile, null); | ||
| } catch (\Nette\InvalidStateException | \Nette\FileNotFoundException $e) { | ||
| $errorOutput->writeln($e->getMessage()); | ||
| $application->renderException($e); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this change? The message is usually about which file wasn't found which is sufficient. |
||
| throw new \PHPStan\Command\InceptionNotSuccessfulException(); | ||
| } | ||
| $defaultParameters = [ | ||
|
|
@@ -302,7 +304,8 @@ public static function begin( | |
| require_once $file; | ||
| })($bootstrapFile); | ||
| } catch (\Throwable $e) { | ||
| $errorOutput->writeln($e->getMessage()); | ||
| $application->renderException($e); | ||
|
|
||
| throw new \PHPStan\Command\InceptionNotSuccessfulException(); | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a Exception thrown within a command will automatically lead to a exit-code of
1by symfony-consoleThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I disagree with this change. CommandHelper outputs the error message, InceptionNotSuccessfulException signals the AnalyseCommand to return the exit code 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change would lead to a really chaotic output in most cases which isn't needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
symfony will automatically use a exit-code of 1 when a un-handled exception occurs.
no need to do this here and interrupt the exception handling
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the cause of chaotic output is that the output is scattered accross CommandHelper and the actual commands. output should be written only in a few places in the upper stack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the problem is that I don't always want to output the thrown exception with stack trace. I want to present something more friendly to the user.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when letting the exception fly through we would get a error like (no stacktrace)
no stacktrace or similar involved.
you get the stacktrace etc. only when adding
-vto the command: