Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codegen: Add codegen error #841

Merged
merged 13 commits into from
Mar 3, 2023
114 changes: 57 additions & 57 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added artifacts/polkadot_metadata_tmp.scale
Binary file not shown.
10 changes: 9 additions & 1 deletion cli/src/commands/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ fn codegen(
type_substitutes,
crate_path,
);
println!("{runtime_api}");
match runtime_api {
Ok(runtime_api) => println!("{runtime_api}"),
Err(e) => {
// `Span` cannot be sent between threads.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this comment, is that the reason why you can't propagate the error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CodegenError includes a Span in some variants that can be used to hint at better compile errors.
The color_eyre does impose StdError + Send + Sync on the returned error, to circumvent that I've just printed the error message in red. I'll update the comment :D

use color_eyre::owo_colors::OwoColorize;
println!("{}", e.to_string().red())
}
};

Ok(())
}
2 changes: 1 addition & 1 deletion codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ darling = "0.14.3"
frame-metadata = "15.0.0"
heck = "0.4.1"
proc-macro2 = "1.0.51"
proc-macro-error = "1.0.4"
quote = "1.0.8"
syn = "1.0.109"
scale-info = "2.0.0"
subxt-metadata = { version = "0.27.1", path = "../metadata" }
jsonrpsee = { version = "0.16.0", features = ["async-client", "client-ws-transport", "http-client"] }
hex = "0.4.3"
tokio = { version = "1.25", features = ["macros", "rt-multi-thread"] }
thiserror = "1.0.24"

[dev-dependencies]
bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] }
Expand Down
Loading