func recoverPanic()

in funcframework/framework.go [52:63]


func recoverPanic(w http.ResponseWriter, panicSrc string, shouldPanic bool) {
	if r := recover(); r != nil {
		genericMsg := fmt.Sprintf(panicMessageTmpl, panicSrc)
		fmt.Fprintf(os.Stderr, "%s\npanic message: %v\nstack trace: %v\n%s", genericMsg, r, r, debug.Stack())
		if w != nil {
			writeHTTPErrorResponse(w, http.StatusInternalServerError, crashStatus, genericMsg)
		}
		if shouldPanic {
			panic(r)
		}
	}
}