mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-23 00:56:45 +01:00
http: Avoid panic if handler errors lack underlying error value
Fixes #2845
This commit is contained in:
parent
0dd9243478
commit
8d3c64932e
1 changed files with 5 additions and 1 deletions
|
@ -368,7 +368,11 @@ type ServerLogConfig struct {
|
||||||
func errLogValues(err error) (status int, msg string, fields []zapcore.Field) {
|
func errLogValues(err error) (status int, msg string, fields []zapcore.Field) {
|
||||||
if handlerErr, ok := err.(HandlerError); ok {
|
if handlerErr, ok := err.(HandlerError); ok {
|
||||||
status = handlerErr.StatusCode
|
status = handlerErr.StatusCode
|
||||||
|
if handlerErr.Err == nil {
|
||||||
|
msg = err.Error()
|
||||||
|
} else {
|
||||||
msg = handlerErr.Err.Error()
|
msg = handlerErr.Err.Error()
|
||||||
|
}
|
||||||
fields = []zapcore.Field{
|
fields = []zapcore.Field{
|
||||||
zap.Int("status", handlerErr.StatusCode),
|
zap.Int("status", handlerErr.StatusCode),
|
||||||
zap.String("err_id", handlerErr.ID),
|
zap.String("err_id", handlerErr.ID),
|
||||||
|
|
Loading…
Reference in a new issue