From cec01f1328f33a429f791f2a44cf27f44e2458c9 Mon Sep 17 00:00:00 2001 From: Sridhar Ganesan Date: Mon, 23 Jul 2018 19:04:33 +0200 Subject: [PATCH] Changing the way error messages are displayed --- cmd/cosmos-sdk-cli/cmd/init.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/cmd/cosmos-sdk-cli/cmd/init.go b/cmd/cosmos-sdk-cli/cmd/init.go index e31820e818..3b42c53757 100644 --- a/cmd/cosmos-sdk-cli/cmd/init.go +++ b/cmd/cosmos-sdk-cli/cmd/init.go @@ -46,7 +46,10 @@ var initCmd = &cobra.Command{ remoteBasecoinPath, remoteProjectPath, "basecoin", shortProjectName, "Basecoin", capitalizedProjectName) - setupBasecoinWorkspace(shortProjectName, remoteProjectPath) + err := setupBasecoinWorkspace(shortProjectName, remoteProjectPath) + if err != nil { + return err + } return nil }, } @@ -143,16 +146,16 @@ benchmark: } -func setupBasecoinWorkspace(projectName string, remoteProjectPath string) { +func setupBasecoinWorkspace(projectName string, remoteProjectPath string) error { projectPath := resolveProjectPath(remoteProjectPath) fmt.Println("Configuring your project in " + projectPath) // Check if the projectPath already exists or not - if _, err := os.Stat(projectPath); os.IsNotExist(err) { - copyBasecoinTemplate(projectName, projectPath, remoteProjectPath) - createGopkg(projectPath) - createMakefile(projectPath) - fmt.Printf("Initialized a new project at %s.\nHappy hacking!\n", projectPath) - } else { - fmt.Errorf("%s already exists, please choose a different project path\n", projectPath) + if _, err := os.Stat(projectPath); !os.IsNotExist(err) { + return fmt.Errorf("Unable to initialize the project. %s already exists", projectPath) } + copyBasecoinTemplate(projectName, projectPath, remoteProjectPath) + createGopkg(projectPath) + createMakefile(projectPath) + fmt.Printf("Initialized a new project at %s.\nHappy hacking!\n", projectPath) + return nil }