From 29b81e9b3f97292ce4d816ddd49c0f7d9d527c2c Mon Sep 17 00:00:00 2001 From: 0x2b3bfa0 <0x2b3bfa0+git@googlemail.com> Date: Thu, 27 May 2021 16:44:54 +0200 Subject: [PATCH 1/2] Improve GitLab API finder error handling --- src/drivers/gitlab.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/drivers/gitlab.js b/src/drivers/gitlab.js index 0715a86e8..b43e9d915 100644 --- a/src/drivers/gitlab.js +++ b/src/drivers/gitlab.js @@ -53,12 +53,19 @@ class Gitlab { .version ) return path; - } catch (error) {} + } catch (error) { + return error; + } }) ); - this._detected_base = possible_bases.find(Boolean); - if (!this._detected_base) throw new Error('GitLab API not found'); + this._detected_base = possible_bases.find( + (base) => base.constructor !== Error + ); + if (!this._detected_base) { + if (possible_bases.length) throw possible_bases[0]; + else throw new Error('Invalid repository address'); + } return this._detected_base; } From fefbdda69c2caf11abd1eb5af90bfcb0958e3ec0 Mon Sep 17 00:00:00 2001 From: Helio Machado <0x2b3bfa0+git@googlemail.com> Date: Thu, 27 May 2021 19:50:16 +0200 Subject: [PATCH 2/2] Remove redundant else --- src/drivers/gitlab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/drivers/gitlab.js b/src/drivers/gitlab.js index b50082a4d..85a9dd677 100644 --- a/src/drivers/gitlab.js +++ b/src/drivers/gitlab.js @@ -64,7 +64,7 @@ class Gitlab { ); if (!this.detectedBase) { if (possibleBases.length) throw possibleBases[0]; - else throw new Error('Invalid repository address'); + throw new Error('Invalid repository address'); } return this.detectedBase;