Skip to content

Commit a17f8da

Browse files
committed
fix: add better debugging for fetch failures
1 parent 64a721f commit a17f8da

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/lib/readmeAPIFetch.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -190,17 +190,22 @@ export default async function readmeAPIFetch(
190190
...options,
191191
headers,
192192
dispatcher: proxy ? new ProxyAgent(proxy) : undefined,
193-
}).then(res => {
194-
const warningHeader = res.headers.get('Warning');
195-
if (warningHeader) {
196-
debug(`received warning header: ${warningHeader}`);
197-
const warnings = parseWarningHeader(warningHeader);
198-
warnings.forEach(warning => {
199-
warn(warning.message, 'ReadMe API Warning:');
200-
});
201-
}
202-
return res;
203-
});
193+
})
194+
.then(res => {
195+
const warningHeader = res.headers.get('Warning');
196+
if (warningHeader) {
197+
debug(`received warning header: ${warningHeader}`);
198+
const warnings = parseWarningHeader(warningHeader);
199+
warnings.forEach(warning => {
200+
warn(warning.message, 'ReadMe API Warning:');
201+
});
202+
}
203+
return res;
204+
})
205+
.catch(e => {
206+
debug(`error making fetch request: ${e}`);
207+
throw e;
208+
});
204209
}
205210

206211
/**

0 commit comments

Comments
 (0)