From 87aadd20ec884971d98e2f5cc71ffdfc2924eb59 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 6 Oct 2015 11:12:11 -0700 Subject: [PATCH] Improve mirror error message --- cp-main.go | 4 ++-- mirror-main.go | 6 +++--- session-main.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cp-main.go b/cp-main.go index 28fdf0d9..8195604e 100644 --- a/cp-main.go +++ b/cp-main.go @@ -209,7 +209,7 @@ func doPrepareCopyURLs(session *sessionV2, trapCh <-chan bool) { session.Save() } -func doCopyCmdSession(session *sessionV2) { +func doCopySession(session *sessionV2) { trapCh := signalTrap(os.Interrupt, os.Kill) if !session.HasData() { @@ -334,6 +334,6 @@ func mainCopy(ctx *cli.Context) { fatalIf(err.Trace(), "One or more unknown URL types passed.") } - doCopyCmdSession(session) + doCopySession(session) session.Delete() } diff --git a/mirror-main.go b/mirror-main.go index 5c414b9e..dfc2862d 100644 --- a/mirror-main.go +++ b/mirror-main.go @@ -208,7 +208,7 @@ func doPrepareMirrorURLs(session *sessionV2, trapCh <-chan bool) { session.Save() } -func doMirrorCmdSession(session *sessionV2) { +func doMirrorSession(session *sessionV2) { trapCh := signalTrap(os.Interrupt, os.Kill) if !session.HasData() { @@ -256,13 +256,13 @@ func doMirrorCmdSession(session *sessionV2) { if !globalQuietFlag && !globalJSONFlag { console.Eraseline() } + errorIf(sURLs.Error.Trace(), fmt.Sprintf("Failed to mirror ā€˜%s’.", sURLs.SourceContent.Name)) // all the cases which are handled where session should be saved are contained in the following // switch case, we shouldn't be saving sessions for all errors since some errors might need to be // reported to user properly. // // All other critical cases should be handled properly gracefully // handle more errors and save the session. - errorIf(sURLs.Error.Trace(), "Failed to mirror.") switch sURLs.Error.ToGoError().(type) { case *net.OpError: gracefulSessionSave(session) @@ -333,6 +333,6 @@ func mainMirror(ctx *cli.Context) { fatalIf(err.Trace(ctx.Args()...), fmt.Sprintf("One or more unknown argument types found in ā€˜%s’.", ctx.Args())) } - doMirrorCmdSession(session) + doMirrorSession(session) session.Delete() } diff --git a/session-main.go b/session-main.go index be0d8627..cecb1de8 100644 --- a/session-main.go +++ b/session-main.go @@ -134,9 +134,9 @@ func clearSession(sid string) { func sessionExecute(s *sessionV2) { switch s.Header.CommandType { case "cp": - doCopyCmdSession(s) + doCopySession(s) case "mirror": - doMirrorCmdSession(s) + doMirrorSession(s) } }