fixed drop errors for database initialization
This commit is contained in:
@ -60,10 +60,14 @@ impl Database {
|
||||
db.enums.insert(def.name.clone(), def);
|
||||
}
|
||||
Err(e) => {
|
||||
let name = item.get("name").and_then(|v| v.as_str()).unwrap_or("unknown");
|
||||
errors.push(crate::drop::Error {
|
||||
code: "DATABASE_ENUM_PARSE_FAILED".to_string(),
|
||||
message: format!("Failed to parse database enum: {}", e),
|
||||
details: crate::drop::ErrorDetails::default(),
|
||||
message: format!("Failed to parse database enum '{}': {}", name, e),
|
||||
details: crate::drop::ErrorDetails {
|
||||
context: Some(serde_json::json!(name)),
|
||||
..Default::default()
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -77,10 +81,14 @@ impl Database {
|
||||
db.types.insert(def.name.clone(), def);
|
||||
}
|
||||
Err(e) => {
|
||||
let name = item.get("name").and_then(|v| v.as_str()).unwrap_or("unknown");
|
||||
errors.push(crate::drop::Error {
|
||||
code: "DATABASE_TYPE_PARSE_FAILED".to_string(),
|
||||
message: format!("Failed to parse database type: {}", e),
|
||||
details: crate::drop::ErrorDetails::default(),
|
||||
message: format!("Failed to parse database type '{}': {}", name, e),
|
||||
details: crate::drop::ErrorDetails {
|
||||
context: Some(serde_json::json!(name)),
|
||||
..Default::default()
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -98,10 +106,14 @@ impl Database {
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
let constraint = item.get("constraint").and_then(|v| v.as_str()).unwrap_or("unknown");
|
||||
errors.push(crate::drop::Error {
|
||||
code: "DATABASE_RELATION_PARSE_FAILED".to_string(),
|
||||
message: format!("Failed to parse database relation: {}", e),
|
||||
details: crate::drop::ErrorDetails::default(),
|
||||
message: format!("Failed to parse database relation '{}': {}", constraint, e),
|
||||
details: crate::drop::ErrorDetails {
|
||||
context: Some(serde_json::json!(constraint)),
|
||||
..Default::default()
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -115,10 +127,14 @@ impl Database {
|
||||
db.puncs.insert(def.name.clone(), def);
|
||||
}
|
||||
Err(e) => {
|
||||
let name = item.get("name").and_then(|v| v.as_str()).unwrap_or("unknown");
|
||||
errors.push(crate::drop::Error {
|
||||
code: "DATABASE_PUNC_PARSE_FAILED".to_string(),
|
||||
message: format!("Failed to parse database punc: {}", e),
|
||||
details: crate::drop::ErrorDetails::default(),
|
||||
message: format!("Failed to parse database punc '{}': {}", name, e),
|
||||
details: crate::drop::ErrorDetails {
|
||||
context: Some(serde_json::json!(name)),
|
||||
..Default::default()
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -135,7 +151,10 @@ impl Database {
|
||||
errors.push(crate::drop::Error {
|
||||
code: "DATABASE_SCHEMA_PARSE_FAILED".to_string(),
|
||||
message: format!("Failed to parse database schema key '{}': {}", key, e),
|
||||
details: crate::drop::ErrorDetails::default(),
|
||||
details: crate::drop::ErrorDetails {
|
||||
context: Some(serde_json::json!(key)),
|
||||
..Default::default()
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -282,7 +301,7 @@ impl Database {
|
||||
// Abort relation discovery early if no hierarchical inheritance match was found
|
||||
if matching_rels.is_empty() {
|
||||
let mut details = crate::drop::ErrorDetails {
|
||||
path: path.to_string(),
|
||||
path: Some(path.to_string()),
|
||||
..Default::default()
|
||||
};
|
||||
if let Some(sid) = schema_id {
|
||||
@ -381,7 +400,7 @@ impl Database {
|
||||
// and forces a clean structural error for the architect.
|
||||
if !resolved {
|
||||
let mut details = crate::drop::ErrorDetails {
|
||||
path: path.to_string(),
|
||||
path: Some(path.to_string()),
|
||||
context: serde_json::to_value(&matching_rels).ok(),
|
||||
cause: Some("Multiple conflicting constraints found matching prefixes".to_string()),
|
||||
..Default::default()
|
||||
|
||||
@ -103,7 +103,7 @@ impl Schema {
|
||||
types
|
||||
),
|
||||
details: crate::drop::ErrorDetails {
|
||||
path: path.clone(),
|
||||
path: Some(path.clone()),
|
||||
schema: Some(root_id.to_string()),
|
||||
..Default::default()
|
||||
}
|
||||
@ -427,7 +427,7 @@ impl Schema {
|
||||
code: "AMBIGUOUS_POLYMORPHISM".to_string(),
|
||||
message: format!("oneOf boundaries must map mathematically unique 'type' or 'kind' discriminators, or strictly contain disjoint primitive types."),
|
||||
details: crate::drop::ErrorDetails {
|
||||
path: path.to_string(),
|
||||
path: Some(path.to_string()),
|
||||
schema: Some(root_id.to_string()),
|
||||
..Default::default()
|
||||
}
|
||||
@ -449,7 +449,7 @@ impl Schema {
|
||||
code: "POLYMORPHIC_COLLISION".to_string(),
|
||||
message: format!("Polymorphic boundary defines multiple candidates mapped to the identical discriminator value '{}'.", val),
|
||||
details: crate::drop::ErrorDetails {
|
||||
path: path.to_string(),
|
||||
path: Some(path.to_string()),
|
||||
schema: Some(root_id.to_string()),
|
||||
..Default::default()
|
||||
}
|
||||
@ -491,7 +491,7 @@ impl Schema {
|
||||
c, field_name, id
|
||||
),
|
||||
details: crate::drop::ErrorDetails {
|
||||
path: path.to_string(),
|
||||
path: Some(path.to_string()),
|
||||
schema: Some(root_id.to_string()),
|
||||
..Default::default()
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user