diff --git a/config.go b/config.go index 5dd73748..dd957122 100644 --- a/config.go +++ b/config.go @@ -70,7 +70,7 @@ func getMcConfigDir() (string, *probe.Error) { // mustGetMcConfigDir - construct minio client config folder or fail func mustGetMcConfigDir() (configDir string) { configDir, err := getMcConfigDir() - fatalIf(err.Trace(), "Unable to get mcConfigDir") + fatalIf(err.Trace(), "Unable to get mcConfigDir.") return configDir } @@ -99,7 +99,7 @@ func getMcConfigPath() (string, *probe.Error) { // mustGetMcConfigPath - similar to getMcConfigPath, ignores errors func mustGetMcConfigPath() string { path, err := getMcConfigPath() - fatalIf(err.Trace(), "Unable to get mcConfigPath") + fatalIf(err.Trace(), "Unable to get mcConfigPath.") return path } @@ -138,7 +138,7 @@ func getMcConfig() (*configV2, *probe.Error) { // mustGetMcConfig - reads configuration file and returns configs, exits on error func mustGetMcConfig() *configV2 { config, err := getMcConfig() - fatalIf(err.Trace(), "Unable to get mcConfig") + fatalIf(err.Trace(), "Unable to get mcConfig.") return config } @@ -186,7 +186,7 @@ func migrateConfigV1ToV101() { return } mcConfigV1, err := quick.Load(mustGetMcConfigPath(), newConfigV1()) - fatalIf(err.Trace(), "Unable to load config") + fatalIf(err.Trace(), "Unable to load config.") // update to newer version if mcConfigV1.Version() == "1.0.0" { @@ -212,12 +212,12 @@ func migrateConfigV1ToV101() { } mcNewConfigV101, err := quick.New(confV101) - fatalIf(err.Trace(), "Unable to initialize quick config") + fatalIf(err.Trace(), "Unable to initialize quick config.") err = mcNewConfigV101.Save(mustGetMcConfigPath()) - fatalIf(err.Trace(), "Unable to save config") + fatalIf(err.Trace(), "Unable to save config.") - console.Infof("Successfully migrated %s from version: 1.0.0 to version: 1.0.1\n", mustGetMcConfigPath()) + console.Infof("Successfully migrated %s from version ‘1.0.0’ to version ‘1.0.1’.\n", mustGetMcConfigPath()) } } @@ -226,7 +226,7 @@ func migrateConfigV101ToV2() { return } mcConfigV101, err := quick.Load(mustGetMcConfigPath(), newConfigV101()) - fatalIf(err.Trace(), "Unable to load config") + fatalIf(err.Trace(), "Unable to load config.") // update to newer version if mcConfigV101.Version() == "1.0.1" { @@ -234,12 +234,12 @@ func migrateConfigV101ToV2() { confV2.Version = globalMCConfigVersion mcNewConfigV2, err := quick.New(confV2) - fatalIf(err.Trace(), "Unable to initialize quick config") + fatalIf(err.Trace(), "Unable to initialize quick config.") err = mcNewConfigV2.Save(mustGetMcConfigPath()) - fatalIf(err.Trace(), "Unable to save config") + fatalIf(err.Trace(), "Unable to save config.") - console.Infof("Successfully migrated %s from version: 1.0.1 to version: 2\n", mustGetMcConfigPath()) + console.Infof("Successfully migrated %s from version ‘1.0.1’ to version: ‘2’.\n", mustGetMcConfigPath()) } } diff --git a/error.go b/error.go index bf481098..0d306c21 100644 --- a/error.go +++ b/error.go @@ -48,7 +48,7 @@ func fatalIf(err *probe.Error, msg string) { } json, err := json.Marshal(errorMessage) if err != nil { - panic(err) + console.Fatalln(probe.NewError(err)) } console.Println(string(json)) os.Exit(1) @@ -82,7 +82,7 @@ func errorIf(err *probe.Error, msg string) { } json, err := json.Marshal(errorMessage) if err != nil { - panic(err) + console.Fatalln(probe.NewError(err)) } console.Println(string(json)) return diff --git a/ls-main.go b/ls-main.go index 0f37e25c..53d6dff5 100644 --- a/ls-main.go +++ b/ls-main.go @@ -86,7 +86,8 @@ func mainList(ctx *cli.Context) { fatalIf(err.Trace(arg), "Unable to parse argument ‘"+arg+"’.") // if recursive strip off the "..." - fatalIf(doListCmd(stripRecursiveURL(targetURL), isURLRecursive(targetURL)).Trace(), "Unable to list target ‘"+targetURL+"’.") + err = doListCmd(stripRecursiveURL(targetURL), isURLRecursive(targetURL)) + fatalIf(err.Trace(targetURL), "Unable to list target ‘"+targetURL+"’.") } } @@ -94,7 +95,7 @@ func mainList(ctx *cli.Context) { func doListCmd(targetURL string, recursive bool) *probe.Error { clnt, err := target2Client(targetURL) if err != nil { - return err.Trace() + return err.Trace(targetURL) } - return doList(clnt, recursive).Trace() + return doList(clnt, recursive).Trace(targetURL) } diff --git a/main.go b/main.go index b77d19d4..5b1ab1e6 100644 --- a/main.go +++ b/main.go @@ -150,7 +150,7 @@ VERSION: {{end}} ` app.CommandNotFound = func(ctx *cli.Context, command string) { - fatalIf(probe.NewError(errors.New("")), fmt.Sprintf("Command not found: ‘%s’", command)) + fatalIf(probe.NewError(errors.New("")), fmt.Sprintf("Command ‘%s’ not found.", command)) } return app } diff --git a/mirror-main.go b/mirror-main.go index 7952b62d..572a08ee 100644 --- a/mirror-main.go +++ b/mirror-main.go @@ -156,7 +156,7 @@ func doPrepareMirrorURLs(session *sessionV2, trapCh <-chan bool) { break } if sURLs.Error != nil { - errorIf(sURLs.Error, "Unable to prepare mirror arguments.") + errorIf(sURLs.Error.Trace(), "Unable to prepare mirror arguments.") break } if sURLs.isEmpty() { diff --git a/session-main.go b/session-main.go index 1358f8fb..fa064abb 100644 --- a/session-main.go +++ b/session-main.go @@ -86,8 +86,8 @@ func clearSession(sid string) { if sid == "all" { for _, sid := range getSessionIDs() { session, err := loadSessionV2(sid) - fatalIf(err.Trace(sid), "Unable to load session ‘"+sid+"’") - fatalIf(session.Delete().Trace(sid), "Unable to load session ‘"+sid+"’") + fatalIf(err.Trace(sid), "Unable to load session ‘"+sid+"’.") + fatalIf(session.Delete().Trace(sid), "Unable to load session ‘"+sid+"’.") } return } diff --git a/verify-runtime.go b/verify-runtime.go index 74fd52d5..3a0fe082 100644 --- a/verify-runtime.go +++ b/verify-runtime.go @@ -111,7 +111,7 @@ func verifyMCRuntime() { console.Infoln("Configuration written to [" + mustGetMcConfigPath() + "]. Please update your access credentials.") } if !isSessionDirExists() { - fatalIf(createSessionDir(), "Unable to create session dir.") + fatalIf(createSessionDir().Trace(), "Unable to create session dir.") } checkGolangRuntimeVersion() }