Canister xxx trapped explicitly: IDL error: unexpected variant tag

I deploy a rust canister with candid. I call it in command, it return a right message. Like this:

But when I call it in motoko, it return a error message: Canister xxx trapped explicitly: IDL error: unexpected variant tag
How can I fix this bug?

Maybe the Motoko canister is calling that other canister with a wrong type, i.e. the result type as assumed by Motoko is not the type of the response as actually sent by the canister.

BTW, 17_724 is Ok, with an upper case O. If you are trying to to read this using Motoko’s Result type, then this will fail, as the latter is using ok as the tag name.

4 Likes

Yes, the rust Result is different from the motoko Result.
Thanks! :star_struck: