Refactor error handling (#308)

use fmt instead of log

log.Fatal -> return err

set non-zero exit code on error

print to default err log

cleanup

fix vet

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/308
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
Norwin
2020-12-17 00:18:10 +08:00
committed by 6543
parent 287df8a715
commit a948fd7e10
28 changed files with 66 additions and 128 deletions

View File

@ -6,7 +6,6 @@ package milestones
import (
"fmt"
"log"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/context"
@ -62,7 +61,7 @@ func runMilestonesCreate(cmd *cli.Context) error {
State: state,
})
if err != nil {
log.Fatal(err)
return err
}
print.MilestoneDetails(mile)

View File

@ -5,8 +5,6 @@
package milestones
import (
"log"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
@ -53,7 +51,7 @@ func RunMilestonesList(cmd *cli.Context) error {
})
if err != nil {
log.Fatal(err)
return err
}
print.MilestonesList(milestones, ctx.Output, state)