--- a/.travis.yml Sun Apr 30 20:45:40 2017 +0200
+++ b/.travis.yml Sun Apr 30 23:22:09 2017 +0200
@@ -15,5 +15,6 @@
- go get github.com/spf13/viper
- go get github.com/McKael/madon
- go get github.com/ghodss/yaml
+- go get github.com/pkg/errors
- go get github.com/jaytaylor/html2text
- go get github.com/m0t0k1ch1/gomif
--- a/cmd/accounts.go Sun Apr 30 20:45:40 2017 +0200
+++ b/cmd/accounts.go Sun Apr 30 23:22:09 2017 +0200
@@ -6,10 +6,10 @@
package cmd
import (
- "errors"
"os"
"strings"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
--- a/cmd/instance.go Sun Apr 30 20:45:40 2017 +0200
+++ b/cmd/instance.go Sun Apr 30 23:22:09 2017 +0200
@@ -7,11 +7,11 @@
import (
"context"
- "errors"
"os"
"strings"
"github.com/m0t0k1ch1/gomif"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
)
--- a/cmd/madon.go Sun Apr 30 20:45:40 2017 +0200
+++ b/cmd/madon.go Sun Apr 30 23:22:09 2017 +0200
@@ -6,12 +6,11 @@
package cmd
import (
- "errors"
- "fmt"
"strconv"
"strings"
"github.com/McKael/madon"
+ "github.com/pkg/errors"
"github.com/spf13/viper"
)
@@ -52,7 +51,7 @@
}
// Check instance
if _, err := gClient.GetCurrentInstance(); err != nil {
- return fmt.Errorf("could not use provided app secrets")
+ return errors.New("could not use provided app secrets")
}
if verbose {
errPrint("Using provided app secrets")
@@ -66,7 +65,7 @@
gClient, err = madon.NewApp(AppName, scopes, madon.NoRedirect, instanceURL)
if err != nil {
- return fmt.Errorf("app registration failed: %s", err.Error())
+ return errors.Wrap(err, "app registration failed")
}
errPrint("Registred new application.")
@@ -95,9 +94,9 @@
return nil
}
if !verbose && err.Error() == "cannot unmarshal server response: invalid character '<' looking for beginning of value" {
- return fmt.Errorf("login failed (server did not return a JSON response - check your credentials)")
+ return errors.New("login failed (server did not return a JSON response - check your credentials)")
}
- return fmt.Errorf("login failed: %s", err.Error())
+ return errors.Wrap(err, "login failed")
}
// splitIDs splits a list of IDs into an int64 array
--- a/cmd/media.go Sun Apr 30 20:45:40 2017 +0200
+++ b/cmd/media.go Sun Apr 30 23:22:09 2017 +0200
@@ -6,8 +6,7 @@
package cmd
import (
- "errors"
-
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
)
--- a/cmd/notifications.go Sun Apr 30 20:45:40 2017 +0200
+++ b/cmd/notifications.go Sun Apr 30 23:22:09 2017 +0200
@@ -6,8 +6,7 @@
package cmd
import (
- "errors"
-
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/McKael/madon"
--- a/cmd/root.go Sun Apr 30 20:45:40 2017 +0200
+++ b/cmd/root.go Sun Apr 30 23:22:09 2017 +0200
@@ -10,6 +10,7 @@
"io/ioutil"
"os"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@@ -146,7 +147,7 @@
case "", "plain", "json", "yaml", "template":
return nil // Accepted
}
- return fmt.Errorf("output format '%s' not supported", of)
+ return errors.Errorf("output format '%s' not supported", of)
}
// initConfig reads in config file and ENV variables if set.
--- a/cmd/search.go Sun Apr 30 20:45:40 2017 +0200
+++ b/cmd/search.go Sun Apr 30 23:22:09 2017 +0200
@@ -6,9 +6,9 @@
package cmd
import (
- "errors"
"strings"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
)
--- a/cmd/status.go Sun Apr 30 20:45:40 2017 +0200
+++ b/cmd/status.go Sun Apr 30 23:22:09 2017 +0200
@@ -6,10 +6,10 @@
package cmd
import (
- "errors"
"io/ioutil"
"strings"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/McKael/madon"
--- a/cmd/stream.go Sun Apr 30 20:45:40 2017 +0200
+++ b/cmd/stream.go Sun Apr 30 23:22:09 2017 +0200
@@ -6,9 +6,9 @@
package cmd
import (
- "errors"
"io"
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/McKael/madon"
--- a/cmd/toot.go Sun Apr 30 20:45:40 2017 +0200
+++ b/cmd/toot.go Sun Apr 30 23:22:09 2017 +0200
@@ -6,8 +6,7 @@
package cmd
import (
- "errors"
-
+ "github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/McKael/madon"
@@ -76,7 +75,7 @@
fileMediaID, err := uploadFile(opt.mediaFilePath)
if err != nil {
- return nil, errors.New("cannot attach media file: " + err.Error())
+ return nil, errors.Wrap(err, "cannot attach media file")
}
if fileMediaID > 0 {
ids = append(ids, fileMediaID)