Skip to content

Proper Error Handling When No Grounded Node Found #1243

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

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions exporter/SynthesisFusionAddin/src/ErrorHandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def handle_err_top(func: Callable[..., Result[None]]) -> Callable[..., None]:

def wrapper(*args, **kwargs): # type: ignore
result = func(*args, **kwargs)

if result.is_err():
message, severity = result.unwrap_err()
if severity == ErrorSeverity.Fatal:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import enum
import sys
from logging import ERROR
from os import error
from typing import Any, Iterator, cast

import adsk.core
Expand Down Expand Up @@ -221,7 +222,7 @@ def __init__(self, design: adsk.fusion.Design) -> None:
self.grounded = searchForGrounded(design.rootComponent)

if self.grounded is None:
message = "These is no grounded component in this assembly, aborting kinematic export."
message = "There is not a grounded component in this assembly, aborting kinematic export."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I feel this message is a bit unclear. Something I believe would help the user more would be to add "Please pin a component."

gm.ui.messageBox(message)
_____: Err[None] = Err(message, ErrorSeverity.Fatal)
raise RuntimeError()
Expand Down Expand Up @@ -522,12 +523,9 @@ def buildJointPartHierarchy(

return Ok(None)

# I'm fairly certain bubbling this back up is the way to go
except Warning:
return Err(
"Instantiation of the JointParser failed, likely due to a lack of a grounded component in the assembly",
ErrorSeverity.Fatal,
)
except:
progressDialog.progressDialog.hide()
raise RuntimeError()


def populateJoint(simNode: SimulationNode, joints: joint_pb2.Joints, progressDialog: PDMessage) -> Result[None]:
Expand Down
10 changes: 8 additions & 2 deletions exporter/SynthesisFusionAddin/src/UI/ConfigCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,10 @@ def export(exporterOptions: moduleExporterOptions.ExporterOptions) -> None:
exporterOptions.version = docVersion
exporterOptions.materials = 0

Parser.Parser(exporterOptions).export()
try:
Parser.Parser(exporterOptions).export()
except:
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think you should pass errors back to the web ui (using html_args.returnData) to avoid showing a success message

exporterOptions.writeToDesign()

if exporterOptions.openSynthesisUponExport:
Expand Down Expand Up @@ -431,7 +434,10 @@ def notify(self, _: adsk.core.CommandEventArgs) -> None:
try:
Parser.Parser(exporterOptions).export()
except:
pass
jointConfigTab.reset()
gamepieceConfigTab.reset()

return
exporterOptions.writeToDesign()
jointConfigTab.reset()
gamepieceConfigTab.reset()
Expand Down
Loading