Safe JSON parse for fetch responses. Reads the body once and tolerates
non-JSON payloads (e.g. NGINX HTML 5xx gateway pages) by returning a
{ message } shell that downstream error code paths can still consume.
Prevents the failure mode tracked in #1727: callers doing
throw PaymentsError.fromBackend('...', await response.json()) would
otherwise let a SyntaxError from .json() escape and surface as an
unhandledRejection that can take the host Node process down.
Safe JSON parse for fetch responses. Reads the body once and tolerates non-JSON payloads (e.g. NGINX HTML 5xx gateway pages) by returning a
{ message }shell that downstream error code paths can still consume.Prevents the failure mode tracked in #1727: callers doing
throw PaymentsError.fromBackend('...', await response.json())would otherwise let a SyntaxError from.json()escape and surface as anunhandledRejectionthat can take the host Node process down.