Skip to content

Actual response error get's lost when body is not JSON in error case #343

Description

@BreakBB

When the response is not ok the fetcher tries to parse the response body as JSON:

try {
error = await response.json();
} catch (e) {
error = {
status: "unknown" as const,
payload:
e instanceof Error
? \`Unexpected error (\${e.message})\`
: "Unexpected error"
};
}

However when the response body is not JSON or malformed, response.json() throws an "Unexpected end of JSON input" error and the original response error get's lost.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions