Return details in case PAT does not have access

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2023-08-16 11:24:34 +00:00
parent c641e1d596
commit d57e488f12
No known key found for this signature in database
GPG key ID: 7D073DCC2C074CB5
2 changed files with 2 additions and 2 deletions

View file

@ -252,7 +252,7 @@ func (r *organization) listHooks(ctx context.Context) ([]*github.Hook, error) {
hooks, ghResp, err := r.ghcli.ListOrgHooks(ctx, r.cfg.Name, &opts)
if err != nil {
if ghResp != nil && ghResp.StatusCode == http.StatusNotFound {
return nil, errors.Wrap(runnerErrors.ErrNotFound, "fetching hooks")
return nil, runnerErrors.NewBadRequestError("organization not found or your PAT does not have access to manage webhooks")
}
return nil, errors.Wrap(err, "fetching hooks")
}

View file

@ -253,7 +253,7 @@ func (r *repository) listHooks(ctx context.Context) ([]*github.Hook, error) {
hooks, ghResp, err := r.ghcli.ListRepoHooks(ctx, r.cfg.Owner, r.cfg.Name, &opts)
if err != nil {
if ghResp != nil && ghResp.StatusCode == http.StatusNotFound {
return nil, errors.Wrap(runnerErrors.ErrNotFound, "fetching hooks")
return nil, runnerErrors.NewBadRequestError("repository not found or your PAT does not have access to manage webhooks")
}
return nil, errors.Wrap(err, "fetching hooks")
}