tsweb: adjust names and docs of the "handler with errors" functions.

Signed-off-by: David Anderson <dave@natulte.net>
This commit is contained in:
David Anderson
2020-03-17 22:06:30 -07:00
committed by Dave Anderson
parent 131541c06d
commit df4636567f
2 changed files with 35 additions and 24 deletions

View File

@@ -6,7 +6,6 @@ package tsweb
import (
"encoding/json"
"fmt"
"strings"
"time"
)
@@ -42,20 +41,3 @@ func (m Msg) String() string {
json.NewEncoder(&buf).Encode(m)
return strings.TrimRight(buf.String(), "\n")
}
// HTTPError is an error with embedded HTTP response information. When
// received by an ErrHandler, the Code and Msg are sent to the client,
// while Err is logged on the server.
type HTTPError struct {
Code int
Msg string // sent to the end-user
Err error
}
// Error implements the error interface.
func (e HTTPError) Error() string { return fmt.Sprintf("httperror{%d, %q, %v}", e.Code, e.Msg, e.Err) }
// Error returns an HTTPError containing the given information.
func Error(code int, msg string, err error) HTTPError {
return HTTPError{Code: code, Msg: msg, Err: err}
}