11use alloc:: string:: { String , ToString } ;
2+ use alloc:: vec:: Vec ;
23use core:: { fmt:: Display , ops:: ControlFlow } ;
34use tinywasm_types:: FuncType ;
45
@@ -22,12 +23,14 @@ pub enum Error {
2223 /// An unknown error occurred
2324 Other ( String ) ,
2425
25- /// A function did not return a value
26- FuncDidNotReturn ,
27-
28- /// A host function returned results that don't match it's signature
29- HostFuncInvalidReturn ,
30-
26+ /// A host function returned an invalid value
27+ InvalidHostFnReturn {
28+ /// The expected type
29+ expected : FuncType ,
30+ /// The actual value
31+ actual : Vec < tinywasm_types:: WasmValue > ,
32+ } ,
33+
3134 /// An invalid label type was encountered
3235 InvalidLabelType ,
3336
@@ -198,9 +201,9 @@ impl Display for Error {
198201 Self :: InvalidLabelType => write ! ( f, "invalid label type" ) ,
199202 Self :: Other ( message) => write ! ( f, "unknown error: {message}" ) ,
200203 Self :: UnsupportedFeature ( feature) => write ! ( f, "unsupported feature: {feature}" ) ,
201- Self :: FuncDidNotReturn => write ! ( f , "function did not return" ) ,
202- Self :: HostFuncInvalidReturn => write ! ( f, "host function returned invalid types" ) ,
203-
204+ Self :: InvalidHostFnReturn { expected , actual } => {
205+ write ! ( f, "invalid host function return: expected={expected:?}, actual={actual:?}" )
206+ }
204207 Self :: InvalidStore => write ! ( f, "invalid store" ) ,
205208
206209 Self :: UnexpectedSuspend ( _) => write ! ( f, "funtion yielded instead of returning" ) ,
0 commit comments