transparent errors

This commit is contained in:
Tobias Trabelsi 2023-05-17 09:34:11 +02:00
parent 322ad2d3c4
commit 19062e27f0

View file

@ -1,8 +1,8 @@
package gitea package gitea
import ( import (
"errors"
"fmt" "fmt"
"log"
"strconv" "strconv"
"strings" "strings"
@ -108,7 +108,7 @@ func resourceTeamCreate(d *schema.ResourceData, meta interface{}) (err error) {
if !includeAllRepos { if !includeAllRepos {
err = setTeamRepositories(team, d, meta, false) err = setTeamRepositories(team, d, meta, false)
if err != nil { if err != nil {
return return err
} }
} }
@ -195,7 +195,7 @@ func resourceTeamUpdate(d *schema.ResourceData, meta interface{}) (err error) {
if !includeAllRepos { if !includeAllRepos {
err = setTeamRepositories(team, d, meta, true) err = setTeamRepositories(team, d, meta, true)
if err != nil { if err != nil {
return return err
} }
} }
@ -348,8 +348,7 @@ func setTeamRepositories(team *gitea.Team, d *schema.ResourceData, meta interfac
}, },
}) })
if err != nil { if err != nil {
log.Printf("[ERROR] Error listeng team repositories: %s", err) return errors.New(fmt.Sprintf("[ERROR] Error listeng team repositories: %s", err))
return
} }
if len(existingRepositories) == 0 { if len(existingRepositories) == 0 {
break break
@ -362,8 +361,7 @@ func setTeamRepositories(team *gitea.Team, d *schema.ResourceData, meta interfac
} else { } else {
_, err = client.RemoveTeamRepository(team.ID, org, exr.Name) _, err = client.RemoveTeamRepository(team.ID, org, exr.Name)
if err != nil { if err != nil {
log.Printf("[ERROR] Error removing team repository %q: %s", exr.Name, err) return errors.New(fmt.Sprintf("[ERROR] Error removing team repository %q: %s", exr.Name, err))
return
} }
} }
} }
@ -376,8 +374,7 @@ func setTeamRepositories(team *gitea.Team, d *schema.ResourceData, meta interfac
if flag { if flag {
_, err = client.AddTeamRepository(team.ID, org, repo) _, err = client.AddTeamRepository(team.ID, org, repo)
if err != nil { if err != nil {
log.Printf("[ERROR] Error adding team repository %q: %s", repo, err) return errors.New(fmt.Sprintf("[ERROR] Error adding team repository %q: %s", repo, err))
return
} }
} }
} }