gotosocial/vendor/codeberg.org/gruf/go-errors/v2/errors.go
kim 68b91d2128
[performance] tweak http client error handling (#1718)
* 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>
2023-04-29 18:44:20 +02:00

38 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()
}