From 93d475eeb404d0595f4bbfc4670e305cfc29d0c2 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Sun, 23 Feb 2020 20:36:11 +0100
Subject: [PATCH] fix(cdnjs): datasourceError on unknown error

---
 lib/datasource/cdnjs/index.spec.ts | 10 +++++++---
 lib/datasource/cdnjs/index.ts      |  4 ++--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/lib/datasource/cdnjs/index.spec.ts b/lib/datasource/cdnjs/index.spec.ts
index e41973f4c5..4a387baa45 100644
--- a/lib/datasource/cdnjs/index.spec.ts
+++ b/lib/datasource/cdnjs/index.spec.ts
@@ -45,9 +45,11 @@ describe('datasource/cdnjs', () => {
       jest.clearAllMocks();
       return global.renovateCache.rmAll();
     });
-    it('returns null for empty result', async () => {
+    it('throws for empty result', async () => {
       got.mockResolvedValueOnce(null);
-      expect(await getPkgReleases({ lookupName: 'foo/bar' })).toBeNull();
+      await expect(
+        getPkgReleases({ lookupName: 'foo/bar' })
+      ).rejects.toThrowError(DATASOURCE_FAILURE);
     });
     it('returns null for missing fields', async () => {
       got.mockResolvedValueOnce({});
@@ -77,7 +79,9 @@ describe('datasource/cdnjs', () => {
       got.mockImplementationOnce(() => {
         throw new Error();
       });
-      expect(await getPkgReleases({ lookupName: 'foo/bar' })).toBeNull();
+      await expect(
+        getPkgReleases({ lookupName: 'foo/bar' })
+      ).rejects.toThrowError(DATASOURCE_FAILURE);
     });
     it('returns null with wrong auth token', async () => {
       got.mockRejectedValueOnce({ statusCode: 401 });
diff --git a/lib/datasource/cdnjs/index.ts b/lib/datasource/cdnjs/index.ts
index f75a3f0f76..5b83a103ed 100644
--- a/lib/datasource/cdnjs/index.ts
+++ b/lib/datasource/cdnjs/index.ts
@@ -101,13 +101,13 @@ export async function getPkgReleases({
     ) {
       throw new DatasourceError(err);
     }
-
     if (err.statusCode === 401) {
       logger.debug(errorData, 'Authorization error');
     } else if (err.statusCode === 404) {
       logger.debug(errorData, 'Package lookup error');
     } else {
-      logger.warn(errorData, 'CDNJS lookup failure: Unknown error');
+      logger.debug(errorData, 'CDNJS lookup failure: Unknown error');
+      throw new DatasourceError(err);
     }
   }
 
-- 
GitLab