KCL: Use named fields for KclError (#7321)
We've changed the unnamed field of `KclError` variants to a named called `details`. To clarify: previously KCL errors looked like this: ```rust pub enum KclError { Lexical(KclErrorDetails), Syntax(KclErrorDetails), ``` Now they look like this: ```rust pub enum KclError { Lexical { details: KclErrorDetails }, Syntax { details: KclErrorDetails }, } ``` This lets us more easily add fields to the errors. For example, in the UndefinedValue case, adding a field for what the undefined name was. This PR refactors the code to make my PR in https://github.com/KittyCAD/modeling-app/pull/7309 much easier. Pure refactor, should not change any behaviour.
This commit is contained in:
@ -49,7 +49,7 @@ pub(super) fn validate_unique<T: Eq + std::hash::Hash>(tags: &[(T, SourceRange)]
|
||||
}
|
||||
}
|
||||
if !duplicate_tags_source.is_empty() {
|
||||
return Err(KclError::Type(KclErrorDetails::new(
|
||||
return Err(KclError::new_type(KclErrorDetails::new(
|
||||
"The same edge ID is being referenced multiple times, which is not allowed. Please select a different edge"
|
||||
.to_string(),
|
||||
duplicate_tags_source,
|
||||
@ -85,14 +85,14 @@ async fn inner_fillet(
|
||||
// If you try and tag multiple edges with a tagged fillet, we want to return an
|
||||
// error to the user that they can only tag one edge at a time.
|
||||
if tag.is_some() && tags.len() > 1 {
|
||||
return Err(KclError::Type(KclErrorDetails {
|
||||
return Err(KclError::new_type(KclErrorDetails {
|
||||
message: "You can only tag one edge at a time with a tagged fillet. Either delete the tag for the fillet fn if you don't need it OR separate into individual fillet functions for each tag.".to_string(),
|
||||
source_ranges: vec![args.source_range],
|
||||
backtrace: Default::default(),
|
||||
}));
|
||||
}
|
||||
if tags.is_empty() {
|
||||
return Err(KclError::Semantic(KclErrorDetails {
|
||||
return Err(KclError::new_semantic(KclErrorDetails {
|
||||
source_ranges: vec![args.source_range],
|
||||
message: "You must fillet at least one tag".to_owned(),
|
||||
backtrace: Default::default(),
|
||||
|
Reference in New Issue
Block a user