Skip to content

Commit

Permalink
Have the bindgen tool print the "debug" format of the error. (#2350)
Browse files Browse the repository at this point in the history
Alternative would be ":#" which is more concise, but will not give us
tracebacks, and is the default if you return an Err from main()

Fixes #2324
  • Loading branch information
mhammond authored Dec 12, 2024
1 parent f4b0824 commit b601bac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions uniffi/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ mod uniffi_bindgen;

pub fn uniffi_bindgen_main() {
if let Err(e) = uniffi_bindgen::run_main() {
eprintln!("{e}");
eprintln!("{e:?}");
std::process::exit(1);
}
}

pub fn uniffi_bindgen_swift() {
if let Err(e) = swift::run_main() {
eprintln!("{e}");
eprintln!("{e:?}");
std::process::exit(1);
}
}
4 changes: 3 additions & 1 deletion uniffi_bindgen/src/macro_metadata/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ impl ExtractedItems {
// This works fine, because `MetadataReader` knows when the serialized data is terminated
// and will just ignore the trailing data.
let data = &file_data[offset..];
self.items.push(Metadata::read(data)?);
self.items.push(
Metadata::read(data).with_context(|| format!("extracting metadata for '{name}'"))?,
);
self.names.insert(name.to_string());
Ok(())
}
Expand Down

0 comments on commit b601bac

Please sign in to comment.