Skip to content

Improve concreteness of panic messages in Flush() in echo/response.go #2789

@suwakei

Description

@suwakei

Current Issues

The Response.Flush() method in echo/response.go causes a panic if the http.ResponseWriter it wraps does not support the http.Flusher interface. The current panic message is “response writer flushing is not supported”, which makes it unclear which ResponseWriter type is causing the flushing to be unsupported. This may make debugging somewhat more difficult in the event of a problem.

Proposal

Change panic messages to include specific type information for ResponseWriters that do not support http.Flusher

import (
	"bufio"
	+"fmt"
	"errors"
	"net"
	"net/http"
func (r *Response) Flush() {
	err := http.NewResponseController(r.Writer).Flush()
	if err != nil && errors.Is(err, http.ErrNotSupported) {
		+panic(fmt.Errorf("echo: response writer %T does not support flushing (http.Flusher interface)", r.Writer))
	}
}

Expected Effects

  • Improved debugging efficiency: When Flush is not supported, it becomes clear which ResponseWriter is the culprit, speeding problem identification and resolution.

  • Improved developer experience: More specific error information helps developers understand the cause of problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions