From eff9c0c8c6d32c2060841a9b9b98d9d4b38540b2 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Wed, 17 Nov 2021 10:30:17 +0100 Subject: Refactored to replace github pkg errors dependencies with fmt.Errorf --- pkg/config/action.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'pkg/config/action.go') diff --git a/pkg/config/action.go b/pkg/config/action.go index c63308e..4693040 100644 --- a/pkg/config/action.go +++ b/pkg/config/action.go @@ -1,9 +1,8 @@ package config import ( + "fmt" "strings" - - "github.com/pkg/errors" ) func validateAction(action string) error { @@ -11,44 +10,44 @@ func validateAction(action string) error { switch tokens[0] { case "chmail": if len(tokens) != 1 { - return errors.New("chmail action takes no arguments") + return fmt.Errorf("chmail action takes no arguments") } case "login": if len(tokens) != 1 { - return errors.New("login action takes no arguments") + return fmt.Errorf("login action takes no arguments") } case "menu": if len(tokens) != 2 { - return errors.New("menu action takes exactly one argument") + return fmt.Errorf("menu action takes exactly one argument") } // menu existence is tested in global config case "passwd": if len(tokens) != 1 { - return errors.New("passwd action takes no arguments") + return fmt.Errorf("passwd action takes no arguments") } case "play": if len(tokens) != 2 { - return errors.New("play action takes exactly one argument") + return fmt.Errorf("play action takes exactly one argument") } // game existence is tested in global config case "register": if len(tokens) != 1 { - return errors.New("register action takes no arguments") + return fmt.Errorf("register action takes no arguments") } case "replay": if len(tokens) != 1 { - return errors.New("replay action takes no arguments") + return fmt.Errorf("replay action takes no arguments") } case "watch": if len(tokens) != 1 { - return errors.New("watch action takes no arguments") + return fmt.Errorf("watch action takes no arguments") } case "quit": if len(tokens) != 1 { - return errors.New("quit action takes no arguments") + return fmt.Errorf("quit action takes no arguments") } default: - return errors.New("Invalid action : " + tokens[0]) + return fmt.Errorf("Invalid action : " + tokens[0]) } return nil } -- cgit v1.2.3