mirror of
https://github.com/sourcegraph/jsonrpc2.git
synced 2026-06-18 13:10:02 +02:00
transparently simplify control flow (#83)
This commit is contained in:
parent
534fd43609
commit
2cc94179e1
4 changed files with 72 additions and 89 deletions
|
|
@ -30,20 +30,16 @@ func (h *HandlerWithErrorConfigurer) Handle(ctx context.Context, conn *Conn, req
|
|||
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 e, ok := err.(*Error); ok {
|
||||
resp.Error = e
|
||||
} else if err != nil {
|
||||
resp.Error = &Error{Message: err.Error()}
|
||||
}
|
||||
|
||||
if !req.Notif {
|
||||
if err := conn.SendResponse(ctx, resp); err != nil {
|
||||
if err != ErrClosed || !h.suppressErrClosed {
|
||||
conn.logger.Printf("jsonrpc2 handler: sending response %s: %v\n", resp.ID, err)
|
||||
}
|
||||
}
|
||||
err = conn.SendResponse(ctx, resp)
|
||||
if err != nil && (err != ErrClosed || !h.suppressErrClosed) {
|
||||
conn.logger.Printf("jsonrpc2 handler: sending response %s: %v\n", resp.ID, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue