aboutsummaryrefslogtreecommitdiff
path: root/src/text
diff options
context:
space:
mode:
authorDamien Neil <dneil@google.com>2019-03-27 08:40:12 -0700
committerDamien Neil <dneil@google.com>2019-05-04 16:14:12 +0000
commit170b8b4b12be50eeccbcdadb8523fb4fc670ca72 (patch)
treef379b48b3e9fd304aef9140983b1a2d2ecbe60fa /src/text
parent59ea685ce96a696281e56badd80d2e5dd618b0b0 (diff)
downloadgo-170b8b4b12be50eeccbcdadb8523fb4fc670ca72.tar.gz
go-170b8b4b12be50eeccbcdadb8523fb4fc670ca72.zip
all: add Unwrap and Is methods to various error types
Add Unwrap methods to types which wrap an underlying error: "encodinc/csv".ParseError "encoding/json".MarshalerError "net/http".transportReadFromServerError "net".OpError "net".DNSConfigError "net/url".Error "os/exec".Error "signal/internal/pty".PtyError "text/template".ExecError Add os.ErrTemporary. A case could be made for putting this error value in package net, since no exported error types in package os include a Temporary method. However, syscall errors returned from the os package do include this method. Add Is methods to error types with a Timeout or Temporary method, making errors.Is(err, os.Err{Timeout,Temporary}) equivalent to testing the corresponding method: "context".DeadlineExceeded "internal/poll".TimeoutError "net".adrinfoErrno "net".OpError "net".DNSError "net/http".httpError "net/http".tlsHandshakeTimeoutError "net/pipe".timeoutError "net/url".Error Updates #30322 Updates #29934 Change-Id: I409fb20c072ea39116ebfb8c7534d493483870dc Reviewed-on: https://go-review.googlesource.com/c/go/+/170037 Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Diffstat (limited to 'src/text')
-rw-r--r--src/text/template/exec.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/text/template/exec.go b/src/text/template/exec.go
index 62cf19d30c..0e2ab0e211 100644
--- a/src/text/template/exec.go
+++ b/src/text/template/exec.go
@@ -121,6 +121,10 @@ func (e ExecError) Error() string {
return e.Err.Error()
}
+func (e ExecError) Unwrap() error {
+ return e.Err
+}
+
// errorf records an ExecError and terminates processing.
func (s *state) errorf(format string, args ...interface{}) {
name := doublePercent(s.tmpl.Name())