MetaMask/snaps

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

hmalik88 opened this issue · 2 comments

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.

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].

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 😄