diff options
author | 2021-11-27 15:26:58 +0100 | |
---|---|---|
committer | 2021-11-27 15:26:58 +0100 | |
commit | 182b4eea73881c611a0f519576aa6ad2aa6799c2 (patch) | |
tree | 230fac469690fcee8797b13585e739be148d4789 /vendor/codeberg.org/gruf/go-errors | |
parent | Require confirmed email when checking oauth token (#332) (diff) | |
download | gotosocial-182b4eea73881c611a0f519576aa6ad2aa6799c2.tar.xz |
Update dependencies (#333)
Diffstat (limited to 'vendor/codeberg.org/gruf/go-errors')
-rw-r--r-- | vendor/codeberg.org/gruf/go-errors/data.go | 17 | ||||
-rw-r--r-- | vendor/codeberg.org/gruf/go-errors/errors.go | 19 |
2 files changed, 30 insertions, 6 deletions
diff --git a/vendor/codeberg.org/gruf/go-errors/data.go b/vendor/codeberg.org/gruf/go-errors/data.go index 3a32fd69e..1531c07d4 100644 --- a/vendor/codeberg.org/gruf/go-errors/data.go +++ b/vendor/codeberg.org/gruf/go-errors/data.go @@ -7,17 +7,22 @@ import ( "codeberg.org/gruf/go-logger" ) -// global logfmt data formatter -var logfmt = logger.TextFormat{Strict: false} +// global logfmt data formatter. +var logfmt = logger.TextFormat{ + Strict: logger.DefaultTextFormat.Strict, + MaxDepth: logger.DefaultTextFormat.MaxDepth, + Levels: nil, + TimeFormat: logger.DefaultTextFormat.TimeFormat, +} -// KV is a structure for setting key-value pairs in ErrorData +// KV is a structure for setting key-value pairs in ErrorData. type KV struct { Key string Value interface{} } // ErrorData defines a way to set and access contextual error data. -// The default implementation of this is thread-safe +// The default implementation of this is thread-safe. type ErrorData interface { // Value will attempt to fetch value for given key in ErrorData Value(string) (interface{}, bool) @@ -29,7 +34,7 @@ type ErrorData interface { String() string } -// NewData returns a new ErrorData implementation +// NewData returns a new ErrorData implementation. func NewData() ErrorData { return &errorData{ data: make(map[string]interface{}, 10), @@ -37,7 +42,7 @@ func NewData() ErrorData { } // errorData is our ErrorData implementation, this is essentially -// just a thread-safe string-interface map implementation +// just a thread-safe string-interface map implementation. type errorData struct { data map[string]interface{} buf bytes.Buffer diff --git a/vendor/codeberg.org/gruf/go-errors/errors.go b/vendor/codeberg.org/gruf/go-errors/errors.go index 283bdb098..b1b41bf02 100644 --- a/vendor/codeberg.org/gruf/go-errors/errors.go +++ b/vendor/codeberg.org/gruf/go-errors/errors.go @@ -105,6 +105,25 @@ func Data(err error) ErrorData { return nil } +// UnwrapAll fully unwraps an error stack to produce a string output. +func UnwrapAll(err error) string { + if err == nil { + return "" + } + + // Start error output + out := err.Error() + err = Unwrap(err) + + // Unwrap and append each + for err != nil { + out += ": " + err.Error() + err = Unwrap(err) + } + + return out +} + // stringError is the simplest ErrorContext implementation type stringError string |