~jameinel/juju-core/reflect-only-facades

« back to all changes in this revision

Viewing changes to rpc/server.go

  • Committer: John Arbash Meinel
  • Date: 2014-05-07 13:27:22 UTC
  • Revision ID: john@arbash-meinel.com-20140507132722-7rsvcls3of2rxkgo
transform early rather than late.

It still satisfies the interface and means you don't have
to think about an object when err != nil.

Show diffs side-by-side

added added

removed removed

Lines of Context:
373
373
                if err := conn.readBody(nil, true); err != nil {
374
374
                        return err
375
375
                }
376
 
                // We don't transform the error because there
377
 
                // may be no transformErrors function available.
378
 
                if req.transformErrors != nil {
379
 
                        err = req.transformErrors(err)
380
 
                }
 
376
                // We don't transform the error here. bindRequest will have
 
377
                // already transformed it and returned a zero req.
381
378
                return conn.writeErrorResponse(hdr, err, startTime)
382
379
        }
383
380
        var argp interface{}
473
470
                                Code:    CodeNotImplemented,
474
471
                        }
475
472
                }
 
473
                if transformErrors != nil {
 
474
                        err = transformErrors(err)
 
475
                }
 
476
                return boundRequest{}, err
476
477
        }
477
478
        return boundRequest{
478
479
                MethodCaller:    caller,
479
480
                transformErrors: transformErrors,
480
481
                hdr:             *hdr,
481
 
        }, err
 
482
        }, nil
482
483
}
483
484
 
484
485
// runRequest runs the given request and sends the reply.