aboutsummaryrefslogtreecommitdiff
path: root/src/errors/errors.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/errors/errors.go')
-rw-r--r--src/errors/errors.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/errors/errors.go b/src/errors/errors.go
index b8a46921be..f23a96c43e 100644
--- a/src/errors/errors.go
+++ b/src/errors/errors.go
@@ -6,15 +6,25 @@
package errors
// New returns an error that formats as the given text.
+//
+// The returned error contains a Frame set to the caller's location and
+// implements Formatter to show this information when printed with details.
func New(text string) error {
- return &errorString{text}
+ return &errorString{text, Caller(1)}
}
// errorString is a trivial implementation of error.
type errorString struct {
- s string
+ s string
+ frame Frame
}
func (e *errorString) Error() string {
return e.s
}
+
+func (e *errorString) FormatError(p Printer) (next error) {
+ p.Print(e.s)
+ e.frame.Format(p)
+ return nil
+}