Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions packages/core/errors/fetch-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ class FetchError extends BaseError {
constructor(options = {}) {
const { resource, init, response, responseBody } = options;
const method = init?.method ?? 'GET';
const initText = init
let initText = init
? init.body instanceof URLSearchParams
? (() => {
init.body = init.body.toString();
return JSON.stringify({ init }, null, 2);
})()
init.body = init.body.toString();
return JSON.stringify({ init }, null, 2);
})()
: JSON.stringify({ init }, null, 2)
: '';
: '';

let responseBodyText = '<response body is unavailable>';
if (typeof responseBody === 'string') {
Expand All @@ -35,10 +35,17 @@ class FetchError extends BaseError {
}
}

const responseHeaderText = response
let responseHeaderText = response
? JSON.stringify({ headers: responseHeaders }, null, 2)
: '';

// sanitize error reporting
if (process.env.STAGE !== 'dev') {
initText = false;
responseHeaderText = false;
responseBodyText = false;
}

const messageParts = [
stripIndent`
-----------------------------------------------------
Expand Down
Loading