Skip to content

Commit

Permalink
better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtbuilds committed Nov 1, 2023
1 parent 306201c commit 34800bf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions attr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ impl Intermediate {
pub fn schema_from_filepaths(paths: &[&Path]) -> anyhow::Result<OrmliteSchema> {
let walk = paths.iter().flat_map(Walk::new);

let walk = walk.filter_map(|e| e.ok())
let walk = walk.filter_map(|e| {
if let Err(e) = &e {
tracing::warn!("{}", e.to_string());
}
e.ok()
})
.filter(|e| e.path().extension().map(|e| e == "rs")
.unwrap_or(false))
.map(|e| e.into_path())
Expand All @@ -102,10 +107,10 @@ pub fn schema_from_filepaths(paths: &[&Path]) -> anyhow::Result<OrmliteSchema> {
for entry in walk {
let contents = fs::read_to_string(&entry)
.context(format!("failed to read file: {}", entry.display()))?;
tracing::debug!(file=entry.display().to_string(), "Checking for Model, Type, ManualType derive attrs");
if !contents.contains("Model") {
continue;
}
tracing::debug!(file=entry.display().to_string(), "Checking for derive attrs: Model, Type, ManualType");
let ast = syn::parse_file(&contents)
.context(format!("Failed to parse file: {}", entry.display()))?;
let intermediate = Intermediate::from_with_opts(ast);
Expand Down

0 comments on commit 34800bf

Please sign in to comment.