aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/gopkg.in/urfave/cli.v1/errors.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-01-11 18:14:08 +0800
committerGitHub <noreply@github.com>2017-01-11 18:14:08 +0800
commitb52fde7cf7ce50725830a9d7ddb61e0e8094c7cd (patch)
treeb6b5eb1ac26c2aaef462f48d6f6738d588c44ed4 /vendor/gopkg.in/urfave/cli.v1/errors.go
parent2b4d0b6ff9954de72177980213e7fee0081973d1 (diff)
parentd78f9b834ade0f1ebcf2532bf90d01c85ad50a8e (diff)
downloadgo-tangerine-b52fde7cf7ce50725830a9d7ddb61e0e8094c7cd.tar.gz
go-tangerine-b52fde7cf7ce50725830a9d7ddb61e0e8094c7cd.tar.zst
go-tangerine-b52fde7cf7ce50725830a9d7ddb61e0e8094c7cd.zip
Merge pull request #3546 from fjl/deps-update
vendor: update dependencies
Diffstat (limited to 'vendor/gopkg.in/urfave/cli.v1/errors.go')
-rw-r--r--vendor/gopkg.in/urfave/cli.v1/errors.go28
1 files changed, 23 insertions, 5 deletions
diff --git a/vendor/gopkg.in/urfave/cli.v1/errors.go b/vendor/gopkg.in/urfave/cli.v1/errors.go
index ea551be16..0206ff491 100644
--- a/vendor/gopkg.in/urfave/cli.v1/errors.go
+++ b/vendor/gopkg.in/urfave/cli.v1/errors.go
@@ -24,7 +24,7 @@ func NewMultiError(err ...error) MultiError {
return MultiError{Errors: err}
}
-// Error implents the error interface.
+// Error implements the error interface.
func (m MultiError) Error() string {
errs := make([]string, len(m.Errors))
for i, err := range m.Errors {
@@ -34,6 +34,10 @@ func (m MultiError) Error() string {
return strings.Join(errs, "\n")
}
+type ErrorFormatter interface {
+ Format(s fmt.State, verb rune)
+}
+
// ExitCoder is the interface checked by `App` and `Command` for a custom exit
// code
type ExitCoder interface {
@@ -44,11 +48,11 @@ type ExitCoder interface {
// ExitError fulfills both the builtin `error` interface and `ExitCoder`
type ExitError struct {
exitCode int
- message string
+ message interface{}
}
// NewExitError makes a new *ExitError
-func NewExitError(message string, exitCode int) *ExitError {
+func NewExitError(message interface{}, exitCode int) *ExitError {
return &ExitError{
exitCode: exitCode,
message: message,
@@ -58,7 +62,7 @@ func NewExitError(message string, exitCode int) *ExitError {
// Error returns the string message, fulfilling the interface required by
// `error`
func (ee *ExitError) Error() string {
- return ee.message
+ return fmt.Sprintf("%v", ee.message)
}
// ExitCode returns the exit code, fulfilling the interface required by
@@ -78,7 +82,11 @@ func HandleExitCoder(err error) {
if exitErr, ok := err.(ExitCoder); ok {
if err.Error() != "" {
- fmt.Fprintln(ErrWriter, err)
+ if _, ok := exitErr.(ErrorFormatter); ok {
+ fmt.Fprintf(ErrWriter, "%+v\n", err)
+ } else {
+ fmt.Fprintln(ErrWriter, err)
+ }
}
OsExiter(exitErr.ExitCode())
return
@@ -88,5 +96,15 @@ func HandleExitCoder(err error) {
for _, merr := range multiErr.Errors {
HandleExitCoder(merr)
}
+ return
+ }
+
+ if err.Error() != "" {
+ if _, ok := err.(ErrorFormatter); ok {
+ fmt.Fprintf(ErrWriter, "%+v\n", err)
+ } else {
+ fmt.Fprintln(ErrWriter, err)
+ }
}
+ OsExiter(1)
}