-
Notifications
You must be signed in to change notification settings - Fork 62
Refactor Parser Error Handling #1172
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
base: dev
Are you sure you want to change the base?
Conversation
8171223
to
473f6f3
Compare
Chorus detected one or more security issues with this pull request. See the Checks tab for more details. As a reminder, please follow the secure code review process as part of the Secure Coding Non-Negotiable requirement. |
…/parser-error-handling
exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/Parser.py
Outdated
Show resolved
Hide resolved
…/parser-error-handling
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.
Looking good.
In JointHierarchy.py
there are still some exceptions that are following the old pattern:
synthesis/exporter/SynthesisFusionAddin/src/Parser/SynthesisParser/JointHierarchy.py
Lines 224 to 226 in 1121ac6
if self.grounded is None: | |
gm.ui.messageBox("There is not currently a Grounded Component in the assembly, stopping kinematic export.") | |
raise RuntimeWarning("There is no grounded component") |
This is causing the message box to display with the error AND the full traceback being showed to the user which was the previous behaviour of our logger. Not really sure how we should update this since it's within an init
but we maybe could avoid showing the full traceback to the user and confirm that the export is actually being stopped as described by the messagebox.
Ya this is a tricky one. I think the way to go is to log the message (with the |
14cc761
to
a6e93fa
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 pushed a change that reverted a PWM icon update as the file was being replaced with a question mark. I also merged dev and fixed some merge conflicts.
- It still looks like we are showing the full traceback upon a rigid component not being detected.
- I'm getting an issue where the file name of an exported design is starting with a
v
.

|
Description
The synthesis parser in the exporter now properly handles the errors it was catching, instead of always printing the stacktrace to the user, it now displays clean errors in most cases. This PR also removes the logging wrapper that was previously being used essentially to wrap everything in a
try
-catch
. Errors now propagate through the parser as values with a newResult
class which is inspired by the Rust enum of the same name. Each error contains a message and a severity (Fatal
orWarning
), the latter refers to the severity on the entire parsing process, so an error might cause a function to completely fail, but the error can be recovered by a parent function. On instantiation, eachErr
automatically logs itself based on it's severity. For errors that are not even fatal for the originating function, anErr
should be instantiated but not returned, as to not break control flow.While some were obvious, for several functions, I wasn't entirely sure how/why they would fail (despite them being marked as fallible with
logFailure
), so for those ones, we'll need to switch to the Result-based error handling system as we find errors.Objectives
Result
implementationResult
,Err
, andOk
classesComponents.py
Materials.py
JointHierarchy.py
Joints.py
PDMessage.py
PhysicalProperties.py
RigidGroup.py
(unsure)Utilities.py
Testing Done
JIRA Issue