forked from mirrors/gotosocial
68b91d2128
* update errors library, check for more TLS type error in http client Signed-off-by: kim <grufwub@gmail.com> * bump cache library version to match errors library Signed-off-by: kim <grufwub@gmail.com> --------- Signed-off-by: kim <grufwub@gmail.com>
37 lines
893 B
Go
37 lines
893 B
Go
package errors
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
// New returns a new error created from message.
|
|
func New(msg string) error {
|
|
return create(msg, nil)
|
|
}
|
|
|
|
// Newf returns a new error created from message format and args.
|
|
func Newf(msgf string, args ...interface{}) error {
|
|
return create(fmt.Sprintf(msgf, args...), nil)
|
|
}
|
|
|
|
// Wrap will wrap supplied error within a new error created from message.
|
|
func Wrap(err error, msg string) error {
|
|
return create(msg, err)
|
|
}
|
|
|
|
// Wrapf will wrap supplied error within a new error created from message format and args.
|
|
func Wrapf(err error, msgf string, args ...interface{}) error {
|
|
return create(fmt.Sprintf(msgf, args...), err)
|
|
}
|
|
|
|
// Stacktrace fetches first stored stacktrace of callers from error chain.
|
|
func Stacktrace(err error) Callers {
|
|
var e interface {
|
|
Stacktrace() Callers
|
|
}
|
|
if !errors.As(err, &e) {
|
|
return nil
|
|
}
|
|
return e.Stacktrace()
|
|
}
|