Skip to content

Improve fetch failure error reporting - #105

Merged
emmahoggan merged 2 commits into
mainfrom
eh/improve-fetch-error-diplay
Aug 13, 2026
Merged

Improve fetch failure error reporting#105
emmahoggan merged 2 commits into
mainfrom
eh/improve-fetch-error-diplay

Conversation

@emmahoggan

Copy link
Copy Markdown
Contributor

Context

We were inadvertently squashing fetch failure details. This makes improvements to the error display including:

  • not assuming status/body structure - instead formatting leads with the message (always present), appends status only when set, and appends the body only when present
  • prints the fetch failure 'cause' if available - Node's top level fetch error just presents 'fetch failure', so we now walk the cause chain, append each code, and drops the uninformative "fetch failed" wrapper
  • non-JSON 2xx responses carried no status or body - we now pass the real status and the raw response text, distinguish an empty body, and name the URL

@emmahoggan emmahoggan changed the title Improve fetch failure error reporting - display error details even if… Improve fetch failure error reporting Aug 13, 2026
Comment thread src/http.ts
Comment on lines +122 to +131
const parts: string[] = [];
let current: unknown = error;
while (current instanceof Error) {
const { code } = current as NodeJS.ErrnoException;
const part = code ? `${current.message} (${code})` : current.message;
if (!parts.includes(part)) {
parts.push(part);
}
current = current.cause;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥🔥🔥

@emmahoggan
emmahoggan merged commit bcd2c6a into main Aug 13, 2026
4 checks passed
@emmahoggan
emmahoggan deleted the eh/improve-fetch-error-diplay branch August 13, 2026 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants