MetaMask / snaps

Extend the functionality of MetaMask using Snaps
https://metamask.io/snaps/
Other
723 stars 557 forks source link

Improve superstruct error messaging in `snaps-rpc-methods` #2425

Open hmalik88 opened 4 months ago

hmalik88 commented 4 months ago

This mostly involves work around deeply nested struct definitions i.e. unions of unions. We need a way to reliably throw the correct error and perhaps give a diff of thrown errors all at once.

FrederikBolding commented 4 months ago

For example: Invalid params: At path: ui -- Expected the value to satisfy a union of object | object | object | object | object | object | object | object | object | object | object | object, but received: [object Object].

hmalik88 commented 4 months ago

For example: Invalid params: At path: ui -- Expected the value to satisfy a union of object | object | object | object | object | object | object | object | object | object | object | object, but received: [object Object].

Ah yeah if this is one of the custom ui rpc methods, I think we're using create here to validate params which throws on this first beautiful error 😄