mirror of
https://gitea.com/gitea/tea.git
synced 2026-02-21 22:03:32 +01:00
helpful error messages (#871)
Reviewed-on: https://gitea.com/gitea/tea/pulls/871 Co-authored-by: techknowlogick <techknowlogick@gitea.com> Co-committed-by: techknowlogick <techknowlogick@gitea.com>
This commit is contained in:
committed by
techknowlogick
parent
f638dba99b
commit
4f8cb7ef19
@@ -132,13 +132,16 @@ func runMilestoneIssueAdd(_ stdctx.Context, cmd *cli.Command) error {
|
|||||||
// make sure milestone exist
|
// make sure milestone exist
|
||||||
mile, _, err := client.GetMilestoneByName(ctx.Owner, ctx.Repo, mileName)
|
mile, _, err := client.GetMilestoneByName(ctx.Owner, ctx.Repo, mileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("failed to get milestone '%s': %w", mileName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _, err = client.EditIssue(ctx.Owner, ctx.Repo, idx, gitea.EditIssueOption{
|
_, _, err = client.EditIssue(ctx.Owner, ctx.Repo, idx, gitea.EditIssueOption{
|
||||||
Milestone: &mile.ID,
|
Milestone: &mile.ID,
|
||||||
})
|
})
|
||||||
return err
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to add issue #%d to milestone '%s': %w", idx, mileName, err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func runMilestoneIssueRemove(_ stdctx.Context, cmd *cli.Command) error {
|
func runMilestoneIssueRemove(_ stdctx.Context, cmd *cli.Command) error {
|
||||||
@@ -153,25 +156,28 @@ func runMilestoneIssueRemove(_ stdctx.Context, cmd *cli.Command) error {
|
|||||||
issueIndex := ctx.Args().Get(1)
|
issueIndex := ctx.Args().Get(1)
|
||||||
idx, err := utils.ArgToIndex(issueIndex)
|
idx, err := utils.ArgToIndex(issueIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("invalid issue index '%s': %w", issueIndex, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
issue, _, err := client.GetIssue(ctx.Owner, ctx.Repo, idx)
|
issue, _, err := client.GetIssue(ctx.Owner, ctx.Repo, idx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("failed to get issue #%d: %w", idx, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if issue.Milestone == nil {
|
if issue.Milestone == nil {
|
||||||
return fmt.Errorf("issue is not assigned to a milestone")
|
return fmt.Errorf("issue #%d is not assigned to a milestone", idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
if issue.Milestone.Title != mileName {
|
if issue.Milestone.Title != mileName {
|
||||||
return fmt.Errorf("issue is not assigned to this milestone")
|
return fmt.Errorf("issue #%d is assigned to milestone '%s', not '%s'", idx, issue.Milestone.Title, mileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
zero := int64(0)
|
zero := int64(0)
|
||||||
_, _, err = client.EditIssue(ctx.Owner, ctx.Repo, idx, gitea.EditIssueOption{
|
_, _, err = client.EditIssue(ctx.Owner, ctx.Repo, idx, gitea.EditIssueOption{
|
||||||
Milestone: &zero,
|
Milestone: &zero,
|
||||||
})
|
})
|
||||||
return err
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to remove issue #%d from milestone '%s': %w", idx, mileName, err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ func RunOrganizationDelete(_ stdctx.Context, cmd *cli.Command) error {
|
|||||||
|
|
||||||
response, err := client.DeleteOrg(ctx.Args().First())
|
response, err := client.DeleteOrg(ctx.Args().First())
|
||||||
if response != nil && response.StatusCode == 404 {
|
if response != nil && response.StatusCode == 404 {
|
||||||
return fmt.Errorf("The given organization does not exist")
|
return fmt.Errorf("organization not found: %s", ctx.Args().First())
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user