Builds the structured error envelope for a MetadataCollector result.
Short error code identifying the failure (e.g. 'USER_CANCELLED').
Human-readable description of the failure.
The { error: { code, message } } envelope to set as the
MetadataCollector value.
The returned object routes the server-side connector to its client-error
branch: set it as the collector's form value (via setValue) and resume with
next() as usual. The error envelope is the collector's value, which the
connector routes on, so a well-formed envelope resolves the flow instead of
rejecting the bridge call.
The envelope carries exactly code and message: extra keys inside the
error object pass JS validation but are reconstructed (not forwarded) by
the native setError call on both platforms, so additional context belongs
in the message string, not in envelope extras.
Headless collector normalisation and submit-planning helpers.