Skip to content

Commit 66f9e4c

Browse files
committed
Add warning when a default value isn't parsed
1 parent 9064e64 commit 66f9e4c

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node-graph/gstd/src/text.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@ fn text<'i: 'n>(
1717
#[unit(" px")]
1818
#[default(0.)]
1919
character_spacing: f64,
20-
#[unit(" px")]
21-
#[default(None)]
22-
max_width: Option<f64>,
23-
#[unit(" px")]
24-
#[default(None)]
25-
max_height: Option<f64>,
20+
#[unit(" px")] max_width: Option<f64>,
21+
#[unit(" px")] max_height: Option<f64>,
2622
/// Faux italic.
2723
#[unit("°")]
2824
#[default(0.)]

node-graph/preprocessor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ license = "MIT OR Apache-2.0"
77
[features]
88

99
[dependencies]
10+
log = { workspace = true }
1011

1112
# Workspace dependencies
1213
graphene-std = { workspace = true, features = ["gpu"] }

node-graph/preprocessor/src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#[macro_use]
2+
extern crate log;
3+
14
use graph_craft::document::value::*;
25
use graph_craft::document::*;
36
use graph_craft::proto::RegistryValueSource;
@@ -150,7 +153,14 @@ pub fn node_inputs(fields: &[registry::FieldMetadata], first_node_io: &NodeIOTyp
150153

151154
match field.value_source {
152155
RegistryValueSource::None => {}
153-
RegistryValueSource::Default(data) => return NodeInput::value(TaggedValue::from_primitive_string(data, ty).unwrap_or(TaggedValue::None), exposed),
156+
RegistryValueSource::Default(data) => {
157+
if let Some(custom_default) = TaggedValue::from_primitive_string(data, ty) {
158+
return NodeInput::value(custom_default, exposed);
159+
} else {
160+
// It is incredibly useful to get a warning when the default type cannot be parsed rather than defaulting to `()`.
161+
warn!("Failed to parse default value for type {ty:?} with data {data}");
162+
}
163+
}
154164
RegistryValueSource::Scope(data) => return NodeInput::scope(Cow::Borrowed(data)),
155165
};
156166

0 commit comments

Comments
 (0)