Skip to content

Commit

Permalink
add more error manager
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentli77 committed Oct 14, 2023
1 parent 621632c commit 7fb12ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/provider/github.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ export class GithubProvider implements AbstractRepositoryFactory {
ErrorManager.outputError('Github API rate limit exceeded add token for higher limit')
return
}
if (response.status === 404) {
ErrorManager.outputError(
"Github repository not found ( add token if it's private repository )"
)
return
}
return await response.json()
}

Expand Down
5 changes: 5 additions & 0 deletions src/provider/gitlab.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,17 @@ export class GitlabProvider implements AbstractRepositoryFactory {
public async getRepoContent(route: string) {
const headers: RequestInit = this.token ? { headers: { 'PRIVATE-TOKEN': this.token } } : {}

Check warning on line 57 in src/provider/gitlab.provider.ts

View workflow job for this annotation

GitHub Actions / Running tests...

Object Literal Property name `PRIVATE-TOKEN` must match one of the following formats: camelCase

Check warning on line 57 in src/provider/gitlab.provider.ts

View workflow job for this annotation

GitHub Actions / Running tests...

Object Literal Property name `PRIVATE-TOKEN` must match one of the following formats: camelCase
const response = await fetch(this.baseUrl + route, headers)

if (response.status === 401) {
ErrorManager.outputError(
"Gitlab Bad Credential: Votre token d'authentification est invalide ou expiré."
)
return
}
if (response.status === 403) {
ErrorManager.outputError('Gitlab API rate limit exceeded add token for higher limit')
return
}
if (response.status === 404) {
ErrorManager.outputError(
"Gitlab repository not found ( add token if it's private repository )"
Expand Down

0 comments on commit 7fb12ec

Please sign in to comment.