-
Notifications
You must be signed in to change notification settings - Fork 95
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
Include file path and line number in parsing errors #512
Conversation
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
…heck Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
60be994
to
8213b05
Compare
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
…dformat into aaron/trace_parsing_failure
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
@osrf-jenkins run test |
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 looks great! I have a few minor comments listed below.
Since there were no diff related to this, I couldn't comment in context, but it would also be nice for errors printed via enforceConfigurablePolicyCondition
to contain line numbers. The best way I could think of was changing the enforceConfigurablePolicyCondition
function to take an Error
object instead of std::string
and ErrorCode
.
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
…abs the filename, line number and message from the Error object Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
That's a super good idea! I added that functionality and some tests here, c0ddc7a |
Signed-off-by: Aaron Chong <aaronchongth@gmail.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.
Great work!
Woot, thank you!!! |
@aaronchongth Would it be possible for you to paste a sample of what the end-user now sees w/ the error messages? (just FTR) |
Here's an example using
This feature has already saved me some time! 🎉 I wasn't sure what the |
Sweet, thank you! \cc @SeanCurtis-TRI
|
That's probably an xml syntax error from tinyxml, which is different from the error generated by this PR. |
Are the line numbers only available upon parsing, or are they available in any other context? |
There's an API for getting the file name and line number from any The values are optional because some errors occur in contexts where there is no file. |
So, the line numbers are not available from any other class/element? I.e., it'd be nice to get, say, a "Box" and print something along the lines of: "The Box on line 127 is really friggin' huge. Are you sure you meant that?" It's particularly relevant when we drop into the XML directly for an SDF extension as opposed to an SDF-native element. |
Greetings! Sorry @EricCousineau-TRI, I should have done that in the PR description. Here are some examples of how it looks like
@SeanCurtis-TRI, that's a good point. At this point this will not be able to achieve that. This will probably require the line number and path of each XML element to be embedded into each corresponding |
@aaronchongth You interpreted my question perfectly. I inferred that the described behavior was not available, but it's nice to get official confirmation. I'd certainly vote for line number accessibility as a desirable extension. Not part of this PR, obviously. But some time in the future. |
Sweet! I think that's encoded here: #226 |
🎉 New feature
Closes #479
Summary
This adds file and line number information to parsing errors, specifically when
readXml
is called.Changes to
sdf::Error
:FilePath
andLineNumber
is added to the APIsdf::Error
to accommodate the above new fields<<
now handles printouts depending on the availability ofFilePath
andLineNumber
sdf::Error
has been pimpl-izedChanges to
ign.cc
:<<
operator onsdf::Error
whenign sdf -k <FILE>.sdf
is calledChanges to
readXml
:sdf::Error
Test it
source ws/install/setup.bash ./ws/build/sdformat11/src/UNIT_Error_TEST ./ws/build/sdformat11/src/UNIT_parser_TEST
Checklist
sh tools/code_check.sh
)another open pull request
to support the maintainers
Note to maintainers: Remember to use Squash-Merge