lann opened issue #5416:
Feature
I'd like a specific error for missing imports on e.g.
instantiate_pre
.Benefit
A specific error would give access to the missing import information without parsing the (presumably unstable) message string, and provide access to the missing import's type which is currently inaccessible.
Example code that would benefit from this: https://github.com/fermyon/spin/pull/959/files#diff-3df137e08da293bebdb5cbe1b81fcae6af75992a24c583f47e8040baecbf123aR259
Implementation
Copy the
ImportType
details into a new error struct:pub struct UnknownImport { module: String, name: String, ty: ExternType, }
Expose this info from a method e.g.
import(&self) -> &ImportType
or justAsRef<ImportType>
.Alternatives
New error type(s) could be returned from relevant methods rather than wrapping in
anyhow::Error
. This has been discussed in https://github.com/bytecodealliance/wasmtime/issues/3928.
lann commented on issue #5416:
I'm happy to do the implementation for this if the approach works.
lann edited issue #5416:
Feature
I'd like a specific error for missing imports on e.g.
instantiate_pre
.Benefit
A specific error would give access to the missing import information without parsing the (presumably unstable) message string, and provide access to the missing import's type which is currently inaccessible.
Example code that would benefit from this: https://github.com/fermyon/spin/pull/959/files#diff-3df137e08da293bebdb5cbe1b81fcae6af75992a24c583f47e8040baecbf123aR259
Implementation
Copy the
ImportType
details into a new error struct:pub struct UnknownImport { module: String, name: String, ty: ExternType, }
Expose this info from a method e.g.
import(&self) -> &ImportType
or justAsRef<ImportType>
.Alternatives
New error type(s) could be returned from relevant methods rather than wrapping in
anyhow::Error
. This has been discussed in https://github.com/bytecodealliance/wasmtime/issues/3928.Add some mechanism for returning a list of missing imports, e.g.
Linker::missing_imports(&self, module: &Module) -> impl Iterator<Item = &ImportType>
. I actually quite like this but it would add additional API surface area.
alexcrichton closed issue #5416:
Feature
I'd like a specific error for missing imports on e.g.
instantiate_pre
.Benefit
A specific error would give access to the missing import information without parsing the (presumably unstable) message string, and provide access to the missing import's type which is currently inaccessible.
Example code that would benefit from this: https://github.com/fermyon/spin/pull/959/files#diff-3df137e08da293bebdb5cbe1b81fcae6af75992a24c583f47e8040baecbf123aR259
Implementation
Copy the
ImportType
details into a new error struct:pub struct UnknownImport { module: String, name: String, ty: ExternType, }
Expose this info from a method e.g.
import(&self) -> &ImportType
or justAsRef<ImportType>
.Alternatives
New error type(s) could be returned from relevant methods rather than wrapping in
anyhow::Error
. This has been discussed in https://github.com/bytecodealliance/wasmtime/issues/3928.Add some mechanism for returning a list of missing imports, e.g.
Linker::missing_imports(&self, module: &Module) -> impl Iterator<Item = &ImportType>
. I actually quite like this but it would add additional API surface area.
Last updated: Dec 23 2024 at 12:05 UTC