mirror of
				https://gitea.com/gitea/tea.git
				synced 2025-10-31 01:05:26 +01:00 
			
		
		
		
	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:
		
							
								
								
									
										10
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								main.go
									
									
									
									
									
								
							| @@ -1,4 +1,4 @@ | ||||
| // Copyright 2018 The Gitea Authors. All rights reserved. | ||||
| // Copyright 2020 The Gitea Authors. All rights reserved. | ||||
| // Use of this source code is governed by a MIT-style | ||||
| // license that can be found in the LICENSE file. | ||||
|  | ||||
| @@ -6,7 +6,7 @@ | ||||
| package main // import "code.gitea.io/tea" | ||||
|  | ||||
| import ( | ||||
| 	"log" | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| 	"strings" | ||||
|  | ||||
| @@ -25,7 +25,6 @@ func main() { | ||||
| 	app := cli.NewApp() | ||||
| 	app.Name = "tea" | ||||
| 	app.Usage = "Command line tool to interact with Gitea" | ||||
| 	app.Description = `` | ||||
| 	app.Version = Version + formatBuiltWith(Tags) | ||||
| 	app.Commands = []*cli.Command{ | ||||
| 		&cmd.CmdLogin, | ||||
| @@ -45,7 +44,10 @@ func main() { | ||||
| 	app.EnableBashCompletion = true | ||||
| 	err := app.Run(os.Args) | ||||
| 	if err != nil { | ||||
| 		log.Fatalf("Failed to run app with %s: %v", os.Args, err) | ||||
| 		// app.Run already exits for errors implementing ErrorCoder, | ||||
| 		// so we only handle generic errors with code 1 here. | ||||
| 		fmt.Fprintf(app.ErrWriter, "Error: %v\n", err) | ||||
| 		os.Exit(1) | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Norwin
					Norwin