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] 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; }