From 2c2dff95596faf4b961737bb2e60386c7add97f3 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 3 Apr 2020 10:35:31 -0700 Subject: [PATCH] tsweb: don't panic if we get a tsweb.Error with no embedded error. It's technically weird to return a tsweb.Error with no child err, but it's a sensible thing to want to do, and we shouldn't panic if it happens. Signed-off-by: David Anderson --- tsweb/tsweb.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tsweb/tsweb.go b/tsweb/tsweb.go index 42cd85dd4..00b666342 100644 --- a/tsweb/tsweb.go +++ b/tsweb/tsweb.go @@ -219,7 +219,9 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { case hErrOK: // Handler asked us to send an error. Do so, if we haven't // already sent a response. - msg.Err = hErr.Err.Error() + if hErr.Err != nil { + msg.Err = hErr.Err.Error() + } if lw.code != 0 { h.logf("[unexpected] handler returned HTTPError %v, but already sent a response with code %d", hErr, lw.code) break