handler_with_error.go
func (h *HandlerWithErrorConfigurer) Handle(ctx context.Context, conn *Conn, req *Request) {
	result, err := h.handleFunc(ctx, conn, req)
	if req.Notif {
		if err != nil {
			log.Printf("jsonrpc2 handler: notification %q handling error: %s", req.Method, err)
		}
		return
	}

	resp := &Response{ID: req.ID}
	if err == nil {
		err = resp.SetResult(result)
	}
	if err != nil {
		if e, ok := err.(*Error); ok {
			resp.Error = e
		} else {
			resp.Error = &Error{Message: err.Error()}
		}
	}

	if !req.Notif {
		if err := conn.SendResponse(ctx, resp); err != nil {
			if err != ErrClosed || !h.suppressErrClosed {
				log.Printf("jsonrpc2 handler: sending response %s: %s", resp.ID, err)
			}
		}
	}
}
func (h *HandlerWithErrorConfigurer) Handle(ctx context.Context, conn *Conn, req *Request) {
	result, err := h.handleFunc(ctx, conn, req)
	if req.Notif {
		if err != nil {
			log.Printf("jsonrpc2 handler: notification %q handling error: %s", req.Method, err)
		}
		return
	}

	resp := &Response{ID: req.ID}
	if err == nil {
		err = resp.SetResult(result)
	}
	if err != nil {
		if e, ok := err.(*Error); ok {
			resp.Error = e
		} else {
			resp.Error = &Error{Message: err.Error()}
		}
	}

	if !req.Notif {
		if err := conn.SendResponse(ctx, resp); err != nil {
			if err != ErrClosed || !h.suppressErrClosed {
				log.Printf("jsonrpc2 handler: sending response %s: %s", resp.ID, err)
			}
		}
	}
}
func ( h * HandlerWithErrorConfigurer ) Handle ( ctx context . Context , conn * Conn , req * Request ) { result , err := h . handleFunc ( ctx , conn , req ) if req . Notif { if err != nil { log . Printf ( " " , req . Method , err ) } return } resp := & Response { ID : req . ID } if err == nil { err = resp . SetResult ( result ) } if err != nil { if e , ok := err . ( * Error ) ; ok { resp . Error = e } else { resp . Error = & Error { Message : err . Error ( ) } } } if ! req . Notif { if err := conn . SendResponse ( ctx , resp ) ; err != nil { if err != ErrClosed || ! h . suppressErrClosed { log . Printf ( " " , resp . ID , err ) } } } }
// Handle implements Handler.
Handle implements Handler .