Skip to content

Commit

Permalink
codegen: Add codegen error (#841)
Browse files Browse the repository at this point in the history
* codegen: Add codegen error

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* codegen: Use codegen error instead of aborts

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* codegen: Remove `proc-macro-error` dependency

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* macro/subxt: Transform codegen error into compile_error!

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* cli: Pretty printing for `CodegenError`

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Update cargo.lock

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* tests: Adjust testing for codegen error

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* codegen: Fix documentation example

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* codegen: Export `CodegenError`

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* codegen: Use collect::<Result<_>, _>()

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* cli: Adjust comment regarding error printing

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* codegen: Improve error messages

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
  • Loading branch information
lexnv authored Mar 3, 2023
1 parent 5320ca9 commit a7b45ef
Show file tree
Hide file tree
Showing 18 changed files with 413 additions and 330 deletions.
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 @@ -121,6 +121,14 @@ fn codegen(
crate_path,
should_gen_docs,
);
println!("{runtime_api}");
match runtime_api {
Ok(runtime_api) => println!("{runtime_api}"),
Err(e) => {
// Print the error directly to avoid implementing `Send + Sync` on `CodegenError`.
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

0 comments on commit a7b45ef

Please sign in to comment.