mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-06-02 21:39:25 +00:00
a6c6bdb34a
Bumps codeberg.org/gruf/go-errors/v2 from 2.0.2 to 2.1.1. --- updated-dependencies: - dependency-name: codeberg.org/gruf/go-errors/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
37 lines
876 B
Go
37 lines
876 B
Go
package errors
|
|
|
|
import (
|
|
"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 !As(err, &e) {
|
|
return nil
|
|
}
|
|
return e.Stacktrace()
|
|
}
|