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:
		| @@ -5,7 +5,7 @@ | ||||
| package organizations | ||||
|  | ||||
| import ( | ||||
| 	"log" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"code.gitea.io/tea/modules/context" | ||||
| 	"github.com/urfave/cli/v2" | ||||
| @@ -28,14 +28,12 @@ func RunOrganizationDelete(cmd *cli.Context) error { | ||||
| 	client := ctx.Login.Client() | ||||
|  | ||||
| 	if ctx.Args().Len() < 1 { | ||||
| 		log.Fatal("You have to specify the organization name you want to delete.") | ||||
| 		return nil | ||||
| 		return fmt.Errorf("You have to specify the organization name you want to delete") | ||||
| 	} | ||||
|  | ||||
| 	response, err := client.DeleteOrg(ctx.Args().First()) | ||||
| 	if response != nil && response.StatusCode == 404 { | ||||
| 		log.Fatal("The given organization does not exist.") | ||||
| 		return nil | ||||
| 		return fmt.Errorf("The given organization does not exist") | ||||
| 	} | ||||
|  | ||||
| 	return err | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Norwin
					Norwin