Skip to content

Commit

Permalink
fix: add better debugging for fetch failures
Browse files Browse the repository at this point in the history
  • Loading branch information
kanadgupta committed May 14, 2024
1 parent 64a721f commit a17f8da
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/lib/readmeAPIFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,22 @@ export default async function readmeAPIFetch(
...options,
headers,
dispatcher: proxy ? new ProxyAgent(proxy) : undefined,
}).then(res => {
const warningHeader = res.headers.get('Warning');
if (warningHeader) {
debug(`received warning header: ${warningHeader}`);
const warnings = parseWarningHeader(warningHeader);
warnings.forEach(warning => {
warn(warning.message, 'ReadMe API Warning:');
});
}
return res;
});
})
.then(res => {
const warningHeader = res.headers.get('Warning');
if (warningHeader) {
debug(`received warning header: ${warningHeader}`);
const warnings = parseWarningHeader(warningHeader);
warnings.forEach(warning => {
warn(warning.message, 'ReadMe API Warning:');
});
}
return res;
})
.catch(e => {
debug(`error making fetch request: ${e}`);
throw e;
});
}

/**
Expand Down

0 comments on commit a17f8da

Please sign in to comment.