mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 09:21:05 +00:00
codegen: Add codegen error (#841)
* 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>
This commit is contained in:
+6
-4
@@ -180,7 +180,7 @@ pub fn subxt(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
}
|
||||
|
||||
let mut type_substitutes = TypeSubstitutes::new(&crate_path);
|
||||
type_substitutes.extend(args.substitute_type.into_iter().map(
|
||||
if let Err(err) = type_substitutes.extend(args.substitute_type.into_iter().map(
|
||||
|SubstituteType { ty, with }| {
|
||||
(
|
||||
ty,
|
||||
@@ -190,7 +190,9 @@ pub fn subxt(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
}),
|
||||
)
|
||||
},
|
||||
));
|
||||
)) {
|
||||
return err.into_compile_error().into()
|
||||
}
|
||||
|
||||
let should_gen_docs = args.generate_docs.is_present();
|
||||
match (args.runtime_metadata_path, args.runtime_metadata_url) {
|
||||
@@ -206,7 +208,7 @@ pub fn subxt(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
crate_path,
|
||||
should_gen_docs,
|
||||
)
|
||||
.into()
|
||||
.map_or_else(|err| err.into_compile_error().into(), Into::into)
|
||||
}
|
||||
(None, Some(url_string)) => {
|
||||
let url = Uri::from_str(&url_string).unwrap_or_else(|_| {
|
||||
@@ -220,7 +222,7 @@ pub fn subxt(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||
crate_path,
|
||||
should_gen_docs,
|
||||
)
|
||||
.into()
|
||||
.map_or_else(|err| err.into_compile_error().into(), Into::into)
|
||||
}
|
||||
(None, None) => {
|
||||
abort_call_site!("One of 'runtime_metadata_path' or 'runtime_metadata_url' must be provided")
|
||||
|
||||
Reference in New Issue
Block a user