Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Commit

Permalink
Add Errorf
Browse files Browse the repository at this point in the history
  • Loading branch information
Santi committed Apr 26, 2016
1 parent 7efa461 commit 81ef0ff
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ func (c cause) Error() string { return c.Message() + ": " + c.Cause().Error()
func (c cause) Cause() error { return c.cause }
func (c cause) Message() string { return c.message }

// Errorf returns an error that formats as the given text.
func Errorf(format string, args ...interface{}) error {
pc, _, _, _ := runtime.Caller(1)
return struct {
error
location
}{
fmt.Errorf(format, args...),
location(pc),
}
}

// Wrap returns an error annotating the cause with message.
// If cause is nil, Wrap returns nil.
func Wrap(cause error, message string) error {
Expand Down

0 comments on commit 81ef0ff

Please sign in to comment.