mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-06-03 05:49:40 +00:00
5004e0a9da
* fix error check of prune to allow missing files * update go-store library, add test for pruning item with db entry but no file Signed-off-by: kim <grufwub@gmail.com> * remove now-unneccessary error check Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: kim <grufwub@gmail.com>
37 lines
925 B
Go
37 lines
925 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 a stored stacktrace of callers from an error, or returns nil.
|
|
func Stacktrace(err error) Callers {
|
|
var callers Callers
|
|
if err, ok := err.(interface { //nolint
|
|
Stacktrace() Callers
|
|
}); ok {
|
|
callers = err.Stacktrace()
|
|
}
|
|
return callers
|
|
}
|