-
Notifications
You must be signed in to change notification settings - Fork 6
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
Improve exception message of ExtractionException #34
Conversation
a1757a0
to
ce26755
Compare
@@ -28,8 +28,8 @@ public function parse(\SplFileInfo $file) | |||
|
|||
$content = file_get_contents($file->getRealPath()); | |||
$tokens = Tokens::fromCode($content); | |||
$classNamespace = $namespaceExtractor->extract($tokens); | |||
$className = $classNameExtractor->extract($tokens); | |||
$classNamespace = $namespaceExtractor->extract($tokens, $file); |
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.
i would catch the ExtractionException here and throw a new ParserException indicating the failing file path.
3eabc88
to
225459c
Compare
/** | ||
* @param \SplFileInfo $file | ||
* | ||
* @throws ParseException |
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.
ParseException or ParsingException ?
/** | ||
* Class ParseException. | ||
* | ||
* @author Pierre Allard <pierre.alalrd@akeneo.com> |
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.
allard
af45442
to
392d04f
Compare
392d04f
to
ffd1908
Compare
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.
I don't understand why you need to create a new exception for that, but ok
To avoid to pass the file in the extractor to throw a more accurate exception :) |
$className = $classNameExtractor->extract($tokens); | ||
try { | ||
$classNamespace = $namespaceExtractor->extract($tokens, $file); | ||
$className = $classNameExtractor->extract($tokens, $file); |
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.
you pass a useless $file
param here! (on both lines)
won't do |
When there was an issue on ClassNameExtractor or NamespaceExtractor, the Exception does not link to any file.
This PR improve the exception message to include the errored file.