jspg error refactoring checkpoint
This commit is contained in:
@ -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()
|
||||
|
||||
Reference in New Issue
Block a user