本文整理汇总了Golang中github.com/juju/juju/rpc.Header.Error方法的典型用法代码示例。如果您正苦于以下问题:Golang Header.Error方法的具体用法?Golang Header.Error怎么用?Golang Header.Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/rpc.Header
的用法示例。
在下文中一共展示了Header.Error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ReadHeader
func (c *Codec) ReadHeader(hdr *rpc.Header) error {
c.msg = inMsg{} // avoid any potential cross-message contamination.
var err error
if c.isLogging() {
var m json.RawMessage
err = c.conn.Receive(&m)
if err == nil {
logger.Tracef("<- %s", m)
err = json.Unmarshal(m, &c.msg)
} else {
logger.Tracef("<- error: %v (closing %v)", err, c.isClosing())
}
} else {
err = c.conn.Receive(&c.msg)
}
if err != nil {
// If we've closed the connection, we may get a spurious error,
// so ignore it.
if c.isClosing() || err == io.EOF {
return io.EOF
}
return fmt.Errorf("error receiving message: %v", err)
}
hdr.RequestId = c.msg.RequestId
hdr.Request = rpc.Request{
Type: c.msg.Type,
Id: c.msg.Id,
Action: c.msg.Request,
}
hdr.Error = c.msg.Error
hdr.ErrorCode = c.msg.ErrorCode
return nil
}
示例2: ReadHeader
func (c *Codec) ReadHeader(hdr *rpc.Header) error {
var m json.RawMessage
var version int
err := c.conn.Receive(&m)
if err == nil {
logger.Tracef("<- %s", m)
c.msg, version, err = c.readMessage(m)
} else {
logger.Tracef("<- error: %v (closing %v)", err, c.isClosing())
}
if err != nil {
// If we've closed the connection, we may get a spurious error,
// so ignore it.
if c.isClosing() || err == io.EOF {
return io.EOF
}
return errors.Annotate(err, "error receiving message")
}
hdr.RequestId = c.msg.RequestId
hdr.Request = rpc.Request{
Type: c.msg.Type,
Version: c.msg.Version,
Id: c.msg.Id,
Action: c.msg.Request,
}
hdr.Error = c.msg.Error
hdr.ErrorCode = c.msg.ErrorCode
hdr.Version = version
return nil
}