From 8df59be1d514287e6323aa619ce69a76ce297d3b Mon Sep 17 00:00:00 2001 From: 0HyperCube <78500760+0HyperCube@users.noreply.github.com> Date: Mon, 15 Jan 2024 06:18:08 +0000 Subject: [PATCH] Display graph errors in the viewport (#1577) * Display graph errors in the viewport * Polish up the styling * Clear click targets while graph can't be rendered --------- Co-authored-by: Keavon Chambers --- .../messages/portfolio/portfolio_message_handler.rs | 11 +++++++++++ editor/src/node_graph_executor.rs | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/editor/src/messages/portfolio/portfolio_message_handler.rs b/editor/src/messages/portfolio/portfolio_message_handler.rs index 433862db..2d52e282 100644 --- a/editor/src/messages/portfolio/portfolio_message_handler.rs +++ b/editor/src/messages/portfolio/portfolio_message_handler.rs @@ -634,6 +634,17 @@ impl PortfolioMessageHandler { self.executor.poll_node_graph_evaluation(active_document, responses).unwrap_or_else(|e| { log::error!("Error while evaluating node graph: {e}"); + + let error = r#" + + + The document cannot be rendered in its current state. + Check for error details in the node graph, which can be + opened with the viewport's top right Node Graph button. + /text>"# + // It's a mystery why the `/text>` tag above needs to be missing its `<`, but when it exists it prints the `<` character in the text. However this works with it removed. + .to_string(); + responses.add(FrontendMessage::UpdateDocumentArtwork { svg: error }); }); } } diff --git a/editor/src/node_graph_executor.rs b/editor/src/node_graph_executor.rs index 254d220b..3241f4f0 100644 --- a/editor/src/node_graph_executor.rs +++ b/editor/src/node_graph_executor.rs @@ -558,7 +558,12 @@ impl NodeGraphExecutor { responses.add(BroadcastEvent::DocumentIsDirty); responses.add(OverlaysMessage::Draw); - let node_graph_output = result.map_err(|e| format!("Node graph evaluation failed: {e:?}"))?; + let Ok(node_graph_output) = result else { + // Clear the click targets while the graph is in an un-renderable state + document.metadata.update_click_targets(HashMap::new()); + + return Err("Node graph evaluation failed".to_string()); + }; document.metadata.update_transforms(new_upstream_transforms); document.metadata.update_click_targets(new_click_targets);