mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-01 09:32:35 +02:00
clarify some error messages
This commit is contained in:
parent
0d625c8399
commit
8aa1c0e7ee
3 changed files with 20 additions and 4 deletions
|
@ -49,7 +49,7 @@ const (
|
|||
HealthCheckTimeoutDefault = 5 * time.Second
|
||||
|
||||
WakeTimeoutDefault = "30s"
|
||||
StopTimeoutDefault = "10s"
|
||||
StopTimeoutDefault = "30s"
|
||||
StopMethodDefault = "stop"
|
||||
)
|
||||
|
||||
|
|
|
@ -294,6 +294,9 @@ func (w *Watcher) watchUntilDestroy() (returnCause error) {
|
|||
case errors.Is(err, context.Canceled):
|
||||
continue
|
||||
case err != nil:
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
err = errors.New("timeout waiting for container to stop, please set a higher value for `stop_timeout`")
|
||||
}
|
||||
w.Err(err).Msgf("container stop with method %q failed", w.StopMethod)
|
||||
default:
|
||||
w.LogReason("container stopped", "idle timeout")
|
||||
|
|
|
@ -12,6 +12,7 @@ package reverseproxy
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
@ -207,13 +208,25 @@ func copyHeader(dst, src http.Header) {
|
|||
}
|
||||
|
||||
func (p *ReverseProxy) errorHandler(rw http.ResponseWriter, r *http.Request, err error, writeHeader bool) {
|
||||
reqURL := r.Host + r.RequestURI
|
||||
switch {
|
||||
case errors.Is(err, context.Canceled),
|
||||
errors.Is(err, io.EOF):
|
||||
logger.Debug().Err(err).Str("url", r.URL.String()).Msg("http proxy error")
|
||||
errors.Is(err, io.EOF),
|
||||
errors.Is(err, context.DeadlineExceeded):
|
||||
logger.Debug().Err(err).Str("url", reqURL).Msg("http proxy error")
|
||||
default:
|
||||
logger.Err(err).Str("url", r.URL.String()).Msg("http proxy error")
|
||||
var recordErr tls.RecordHeaderError
|
||||
if errors.As(err, &recordErr) {
|
||||
logger.Error().
|
||||
Str("url", reqURL).
|
||||
Msgf(`scheme was likely misconfigured as https,
|
||||
try setting "proxy.%s.scheme" back to "http"`, p.TargetName)
|
||||
logging.Err(err).Msg("underlying error")
|
||||
} else {
|
||||
logger.Err(err).Str("url", reqURL).Msg("http proxy error")
|
||||
}
|
||||
}
|
||||
|
||||
if writeHeader {
|
||||
rw.WriteHeader(http.StatusInternalServerError)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue