From 0f23c1a3d7f34d32d4c0104eef3955b58d235d3f Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 23 Jul 2015 17:38:47 -0700 Subject: [PATCH] Add proper errors --- cast-url.go | 10 +++++----- cp-url.go | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cast-url.go b/cast-url.go index 5e44511f..acfb203a 100644 --- a/cast-url.go +++ b/cast-url.go @@ -59,7 +59,7 @@ func checkCastSyntax(ctx *cli.Context) { // extract URLs. URLs, err := args2URLs(ctx.Args()) if err != nil { - console.Fatalf("One or more unknown URL types found %s. %s\n", ctx.Args(), iodine.New(err, nil)) + console.Fatalf("One or more unknown URL types found %s. %s\n", ctx.Args(), NewIodine(iodine.New(err, nil))) } srcURL := URLs[0] @@ -71,7 +71,7 @@ func checkCastSyntax(ctx *cli.Context) { _, srcContent, err := url2Stat(srcURL) // Source exist?. if err != nil { - console.Fatalf("Unable to stat source ‘%s’. %s\n", srcURL, iodine.New(err, nil)) + console.Fatalf("Unable to stat source ‘%s’. %s\n", srcURL, NewIodine(iodine.New(err, nil))) } if !srcContent.Type.IsRegular() { if srcContent.Type.IsDir() { @@ -83,7 +83,7 @@ func checkCastSyntax(ctx *cli.Context) { // Recursive URLs are not allowed in target. for _, tgtURL := range tgtURLs { if isURLRecursive(tgtURL) { - console.Fatalf("Target ‘%s’ cannot be recursive. %s\n", tgtURL, iodine.New(err, nil)) + console.Fatalf("Target ‘%s’ cannot be recursive. %s\n", tgtURL, NewIodine(iodine.New(errInvalidArgument{}, nil))) } } @@ -97,11 +97,11 @@ func checkCastSyntax(ctx *cli.Context) { _, srcContent, err := url2Stat(srcURL) // Source exist?. if err != nil { - console.Fatalf("Unable to stat source ‘%s’. %s\n", srcURL, iodine.New(err, nil)) + console.Fatalf("Unable to stat source ‘%s’. %s\n", srcURL, NewIodine(iodine.New(err, nil))) } if srcContent.Type.IsRegular() { // Ellipses is supported only for directories. - console.Fatalf("Source ‘%s’ is not a directory. %s\n", stripRecursiveURL(srcURL), iodine.New(err, nil)) + console.Fatalf("Source ‘%s’ is not a directory. %s\n", stripRecursiveURL(srcURL), NewIodine(iodine.New(err, nil))) } default: diff --git a/cp-url.go b/cp-url.go index f84c6696..52a73c51 100644 --- a/cp-url.go +++ b/cp-url.go @@ -64,7 +64,7 @@ func checkCopySyntax(ctx *cli.Context) { // extract URLs. URLs, err := args2URLs(ctx.Args()) if err != nil { - console.Fatalf("One or more unknown URL types found %s. %s\n", ctx.Args(), iodine.New(err, nil)) + console.Fatalf("One or more unknown URL types found %s. %s\n", ctx.Args(), NewIodine(iodine.New(err, nil))) } srcURLs := URLs[:len(URLs)-1] @@ -73,7 +73,7 @@ func checkCopySyntax(ctx *cli.Context) { /****** Generic rules *******/ // Recursive URLs are not allowed in target. if isURLRecursive(tgtURL) { - console.Fatalf("Target ‘%s’ cannot be recursive. %s\n", tgtURL, iodine.New(err, nil)) + console.Fatalf("Target ‘%s’ cannot be recursive. %s\n", tgtURL, NewIodine(iodine.New(errInvalidArgument{}, nil))) } switch guessCopyURLType(srcURLs, tgtURL) { @@ -87,10 +87,10 @@ func checkCopySyntax(ctx *cli.Context) { _, srcContent, err := url2Stat(srcURL) // Source exist?. if err != nil { - console.Fatalf("Unable to stat source ‘%s’. %s\n", srcURL, iodine.New(err, nil)) + console.Fatalf("Unable to stat source ‘%s’. %s\n", srcURL, NewIodine(iodine.New(err, nil))) } if srcContent.Type.IsRegular() { // Ellipses is supported only for directories. - console.Fatalf("Source ‘%s’ is not a directory. %s\n", stripRecursiveURL(srcURL), iodine.New(err, nil)) + console.Fatalf("Source ‘%s’ is not a directory. %s\n", stripRecursiveURL(srcURL), NewIodine(iodine.New(err, nil))) } } case copyURLsTypeD: