2 Star 2 Fork 1

安徽集萃智能机器人 / zmq4

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
errors.go 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
杨杰 提交于 2023-12-18 14:20 . 拉取zmq4库
package zmq4
/*
#include <zmq.h>
*/
import "C"
import (
"syscall"
)
// An Errno is an unsigned number describing an error condition as returned by a call to ZeroMQ.
// It implements the error interface.
// The number is either a standard system error, or an error defined by the C library of ZeroMQ.
type Errno uintptr
const (
// Error conditions defined by the C library of ZeroMQ.
// On Windows platform some of the standard POSIX errnos are not defined.
EADDRINUSE = Errno(C.EADDRINUSE)
EADDRNOTAVAIL = Errno(C.EADDRNOTAVAIL)
EAFNOSUPPORT = Errno(C.EAFNOSUPPORT)
ECONNABORTED = Errno(C.ECONNABORTED)
ECONNREFUSED = Errno(C.ECONNREFUSED)
ECONNRESET = Errno(C.ECONNRESET)
EHOSTUNREACH = Errno(C.EHOSTUNREACH)
EINPROGRESS = Errno(C.EINPROGRESS)
EMSGSIZE = Errno(C.EMSGSIZE)
ENETDOWN = Errno(C.ENETDOWN)
ENETRESET = Errno(C.ENETRESET)
ENETUNREACH = Errno(C.ENETUNREACH)
ENOBUFS = Errno(C.ENOBUFS)
ENOTCONN = Errno(C.ENOTCONN)
ENOTSOCK = Errno(C.ENOTSOCK)
ENOTSUP = Errno(C.ENOTSUP)
EPROTONOSUPPORT = Errno(C.EPROTONOSUPPORT)
ETIMEDOUT = Errno(C.ETIMEDOUT)
// Native 0MQ error codes.
EFSM = Errno(C.EFSM)
EMTHREAD = Errno(C.EMTHREAD)
ENOCOMPATPROTO = Errno(C.ENOCOMPATPROTO)
ETERM = Errno(C.ETERM)
)
func errget(err error) error {
eno, ok := err.(syscall.Errno)
if ok {
return Errno(eno)
}
return err
}
// Return Errno as string.
func (errno Errno) Error() string {
if errno >= C.ZMQ_HAUSNUMERO {
return C.GoString(C.zmq_strerror(C.int(errno)))
}
return syscall.Errno(errno).Error()
}
/*
Convert error to Errno.
Example usage:
switch AsErrno(err) {
case zmq.Errno(syscall.EINTR):
// standard system error
// call was interrupted
case zmq.ETERM:
// error defined by ZeroMQ
// context was terminated
}
See also: examples/interrupt.go
*/
func AsErrno(err error) Errno {
if eno, ok := err.(Errno); ok {
return eno
}
if eno, ok := err.(syscall.Errno); ok {
return Errno(eno)
}
return Errno(0)
}
func (ctx *Context) retry(err error) bool {
if ctx == nil || !ctx.retryEINTR || err == nil {
return false
}
eno, ok := err.(syscall.Errno)
if !ok {
return false
}
return eno == syscall.EINTR
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/anhui-jicui-intelligent-robot/zmq4.git
git@gitee.com:anhui-jicui-intelligent-robot/zmq4.git
anhui-jicui-intelligent-robot
zmq4
zmq4
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891