Skip to content

Commit

Permalink
Improve GitLab API finder error handling (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x2b3bfa0 committed May 31, 2021
1 parent 9fb3740 commit 6904134
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/drivers/gitlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Gitlab {
}

async repoBase() {
if (this._detected_base) return this._detected_base;
if (this.detectedBase) return this.detectedBase;

const { origin, pathname } = new URL(this.repo);
const possibleBases = await Promise.all(
Expand All @@ -53,14 +53,21 @@ class Gitlab {
.version
)
return path;
} catch (error) {}
} catch (error) {
return error;
}
})
);

this._detected_base = possibleBases.find(Boolean);
if (!this._detected_base) throw new Error('GitLab API not found');
this.detectedBase = possibleBases.find(
(base) => base.constructor !== Error
);
if (!this.detectedBase) {
if (possibleBases.length) throw possibleBases[0];
throw new Error('Invalid repository address');
}

return this._detected_base;
return this.detectedBase;
}

async commentCreate(opts = {}) {
Expand Down

1 comment on commit 6904134

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

Please sign in to comment.