From f5e1afd0bf2fb65035c4d0efa3038ed3e62f3b50 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Tue, 23 Jul 2019 08:47:19 +0200
Subject: [PATCH] fix(github): pass up platform-error for presets

Closes #4152
---
 lib/datasource/github/index.js | 6 ++++++
 test/datasource/github.spec.js | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/lib/datasource/github/index.js b/lib/datasource/github/index.js
index e78a10ae5f..b758893187 100644
--- a/lib/datasource/github/index.js
+++ b/lib/datasource/github/index.js
@@ -22,6 +22,9 @@ async function fetchJSONFile(repo, fileName) {
   try {
     res = await got(url, opts);
   } catch (err) {
+    if (err.message === 'platform-error') {
+      throw err;
+    }
     logger.debug(
       { statusCode: err.statusCodef },
       `Failed to retrieve ${fileName} from repo`
@@ -43,6 +46,9 @@ async function getPreset(pkgName, presetName = 'default') {
       const defaultJson = await fetchJSONFile(pkgName, 'default.json');
       return defaultJson;
     } catch (err) {
+      if (err.message === 'platform-error') {
+        throw err;
+      }
       if (err.message === 'dep not found') {
         logger.info('default.json preset not found - trying renovate.json');
         return fetchJSONFile(pkgName, 'renovate.json');
diff --git a/test/datasource/github.spec.js b/test/datasource/github.spec.js
index aa72db11d1..34ce576300 100644
--- a/test/datasource/github.spec.js
+++ b/test/datasource/github.spec.js
@@ -61,6 +61,14 @@ describe('datasource/github', () => {
     });
   });
   describe('getPreset()', () => {
+    it('passes up platform-error', async () => {
+      got.mockImplementationOnce(() => {
+        throw new Error('platform-error');
+      });
+      await expect(github.getPreset('some/repo')).rejects.toThrow(
+        'platform-error'
+      );
+    });
     it('tries default then renovate', async () => {
       got.mockImplementationOnce(() => {
         throw new Error();
-- 
GitLab