Esempio n. 1
0
func (e Errno) Error() string {
	s := errorStrings[e]
	if s == "" {
		s = C.GoString(C.nn_strerror(C.int(e)))
	}
	return s
}
Esempio n. 2
0
// The errors returned from operations on the nanomsg library and the Go
// bindings for it tries to return all errors using the errors already found in
// Go like syscall.EADDRINUSE. There are some errors that only exists in
// nanomsg and these are defined as Errno.
type Errno syscall.Errno

const (
	nn_hausnumero = Errno(int(C.NN_HAUSNUMERO))

	// Nanomsg specific errors
	ETERM = Errno(int(C.ETERM))
	EFSM  = Errno(int(C.EFSM))
)

var errorStrings = map[Errno]string{
	ETERM: C.GoString(C.nn_strerror(C.ETERM)),
	EFSM:  C.GoString(C.nn_strerror(C.EFSM)),
}

func (e Errno) Error() string {
	s := errorStrings[e]
	if s == "" {
		s = C.GoString(C.nn_strerror(C.int(e)))
	}
	return s
}

// Errors expected to be found when calling the nanomsg library should map
// directly to the syscall.Errno error found in Go. On some platforms, the
// POSIX error is not defined and will most likely be different from the one
// define in the nanomsg library as in the Go world. This map is used to