Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Feature request: don't die on panic #625

Closed
@smacker

Description

@smacker

It would be nice to wrap query handler in defer recover() so in case a query panics it would return an error to the client instead of server exiting.

Similar to how it usually works with http servers:

func(w http.ResponseWriter, r *http.Request) {
	defer func() {
		if rp := recover(); rvr != nil {
			log.Error("panic %v", rp)
			http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
		}
	}()

	next.ServeHTTP(w, r) // actual handler
}

Metadata

Metadata

Assignees

Labels

proposalproposal for new additions or changes

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions