From 093b18375712f2a07840631d956fc43a65c30fc5 Mon Sep 17 00:00:00 2001 From: Badisi Date: Wed, 14 Aug 2024 16:49:42 +0200 Subject: [PATCH] fix!: lint --- projects/lib/specs/schematics.spec.ts | 2 +- projects/lib/src/request.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/lib/specs/schematics.spec.ts b/projects/lib/specs/schematics.spec.ts index f6386d7..c30f486 100644 --- a/projects/lib/specs/schematics.spec.ts +++ b/projects/lib/specs/schematics.spec.ts @@ -52,6 +52,6 @@ describe('schematics', () => { it('helper: getSchematicSchemaOptions - non existing package external', async () => { const test$ = getSchematicSchemaOptions(context, 'sentry', '@hug/non-existing-package', true, 0); - await expectAsync(test$).toBeRejectedWith('Request error (404): https://cdn.jsdelivr.net//npm/@hug/non-existing-package@latest/package.json'); + await expectAsync(test$).toBeRejectedWithError('Request error (404): https://cdn.jsdelivr.net//npm/@hug/non-existing-package@latest/package.json'); }); }); diff --git a/projects/lib/src/request.ts b/projects/lib/src/request.ts index 2782193..940eb45 100644 --- a/projects/lib/src/request.ts +++ b/projects/lib/src/request.ts @@ -23,7 +23,7 @@ export const getDataFromUrl = async (url: string | URL, retries = 3, backoff = 3 try { resolve(Buffer.concat(rawData)); } catch (err) { - reject(err); + reject((err instanceof Error) ? err : new Error(String(err))); } }); } else if (retries > 0) { @@ -31,7 +31,7 @@ export const getDataFromUrl = async (url: string | URL, retries = 3, backoff = 3 } else { res.removeAllListeners(); res.resume(); // consume response data to free up memory - reject(`Request error (${String(res.statusCode)}): https://${hostname}/${pathname}`); + reject(new Error(`Request error (${String(res.statusCode)}): https://${hostname}/${pathname}`)); } }); const abort = (error: Error | string): void => { @@ -40,7 +40,7 @@ export const getDataFromUrl = async (url: string | URL, retries = 3, backoff = 3 } else { req.removeAllListeners(); req.destroy(); - reject(error); + reject((error instanceof Error) ? error : new Error(String(error))); } }; req.once('timeout', () => abort(`Request timed out: https://${hostname}/${pathname}`));