In this example, you have to magically know that DB returns a statusError{} in order not to wrap it again.
I've found one improvement is to encode this knowledge in the type system, by not using plain error returns on the handler, but instead use something like e.g.
type netError interface {
Error() string
Public() bool
StatusCode() int
Unwrap() error
}
func PublicError(e error, code int) netError { ... }
func InternalError(e error) netError { ... }
func SomeHandler(h *http.Request, w http.ReponseWriter) netError { ... }
This makes it clearer whether the underlying err "knows" if it should be public or private.