add more details to StatusErrors
This commit is contained in:
parent
e9eaafae41
commit
6627e8a9b8
4 changed files with 7 additions and 5 deletions
|
|
@ -101,7 +101,7 @@ export class DownloadService {
|
|||
await stream.pipeline(req, fs.createWriteStream(path));
|
||||
} catch (e) {
|
||||
if (e instanceof Got.HTTPError) {
|
||||
throw new StatusError(`${e.response.statusCode} ${e.response.statusMessage}`, e.response.statusCode, e.response.statusMessage, e);
|
||||
throw new StatusError(`download error from ${url}`, e.response.statusCode, e.response.statusMessage, e);
|
||||
} else if (e instanceof Got.RequestError || e instanceof Got.AbortError) {
|
||||
throw new Error(String(e), { cause: e });
|
||||
} else if (e instanceof Error) {
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ export class HttpRequestService {
|
|||
});
|
||||
|
||||
if (!res.ok && extra.throwErrorWhenResponseNotOk) {
|
||||
throw new StatusError(`${res.status} ${res.statusText}`, res.status, res.statusText);
|
||||
throw new StatusError(`request error from ${url}`, res.status, res.statusText);
|
||||
}
|
||||
|
||||
if (res.ok) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue