Improve error message regarding failure to extract metadata from WASM runtime (#1961)

* Improve error message re failure to extract metadata from runtime

* Improve error on legacy metadata loading too

* allow missing host funcs, too
This commit is contained in:
James Wilson
2025-03-13 09:40:50 +00:00
committed by GitHub
parent af59a9960b
commit da3ea0b528
+10 -8
View File
@@ -113,12 +113,14 @@ impl Executor {
.uncached_call(
self.runtime_blob.clone(),
&mut self.externalities,
false,
true,
"Metadata_metadata",
&[],
)
.map_err(|_| {
CodegenError::Wasm("method \"Metadata_metadata\" doesnt exist".to_owned())
.map_err(|e| {
CodegenError::Wasm(format!(
"Failed to call \"Metadata_metadata\" on WASM runtime. Cause: {e}"
))
})?;
let encoded_metadata =
<Vec<u8>>::decode(&mut &encoded_metadata[..]).map_err(CodegenError::Decode)?;
@@ -131,14 +133,14 @@ impl Executor {
.uncached_call(
self.runtime_blob.clone(),
&mut self.externalities,
false,
true,
"Metadata_metadata_at_version",
&version.encode(),
)
.map_err(|_| {
CodegenError::Wasm(
"method \"Metadata_metadata_at_version\" doesnt exist".to_owned(),
)
.map_err(|e| {
CodegenError::Wasm(format!(
"Failed to call \"Metadata_metadata_at_version\" on WASM runtime. Cause: {e}"
))
})?;
let Some(encoded_metadata) =
<Option<Vec<u8>>>::decode(&mut &encoded_metadata[..]).map_err(CodegenError::Decode)?