jspg error refactoring checkpoint

This commit is contained in:
2026-06-23 17:03:27 -04:00
parent fb25224d22
commit d77765cb61
25 changed files with 362 additions and 218 deletions

View File

@ -1,7 +1,8 @@
use crate::drop::{Error, ErrorDetails};
use serde_json::Value;
use std::collections::{HashMap, HashSet};
pub fn compose(val: &mut Value, errors: &mut Vec<crate::drop::Error>) -> Result<(), String> {
pub fn compose(val: &mut Value, errors: &mut Vec<Error>) {
let mut traits = HashMap::new();
let mut schemas = HashMap::new();
@ -56,15 +57,13 @@ pub fn compose(val: &mut Value, errors: &mut Vec<crate::drop::Error>) -> Result<
}
}
}
Ok(())
}
fn resolve_in_place(
current: &mut Value,
traits: &HashMap<String, Value>,
schemas: &HashMap<String, Value>,
errors: &mut Vec<crate::drop::Error>,
errors: &mut Vec<Error>,
schema_id: &str,
path: &str,
visited: &mut HashSet<String>,
@ -118,10 +117,10 @@ fn resolve_in_place(
for inc in include_arr {
if let Some(inc_name) = inc.as_str() {
if visited.contains(inc_name) {
errors.push(crate::drop::Error {
errors.push(Error {
code: "CIRCULAR_INCLUDE_DETECTED".to_string(),
message: format!("Circular inclusion detected for '{}'", inc_name),
details: crate::drop::ErrorDetails {
values: Some(HashMap::from([("include".to_string(), inc_name.to_string())])),
details: ErrorDetails {
schema: Some(schema_id.to_string()),
path: Some(path.to_string()),
..Default::default()
@ -232,10 +231,10 @@ fn resolve_in_place(
}
}
} else {
errors.push(crate::drop::Error {
errors.push(Error {
code: "TRAIT_NOT_FOUND".to_string(),
message: format!("Trait or schema '{}' not found for inclusion", inc_name),
details: crate::drop::ErrorDetails {
values: Some(HashMap::from([("include".to_string(), inc_name.to_string())])),
details: ErrorDetails {
schema: Some(schema_id.to_string()),
path: Some(path.to_string()),
..Default::default()