Skip to content

errors: no obvious way to map error to errno values #29054

Closed as not planned
Closed as not planned
@jech

Description

@jech

go version go1.11.2 linux/amd64

I'm writing some Go code that is called by C code, and I find there's no obvious way to map an error value to a Unix errno value. For example, at one point I write:

        n, err := conn.WriteToUDP(data, &addr)
	if err != nil {
		e := unix.EIO
		if os.IsTimeout(err) {
			e = unix.EAGAIN
		}
                C.set_errno(e)
                return -1
       }

While that keeps the code working, it obviously loses a lot of the error granularity. Given that the errno value must be available somewhere under the hood, it's infuriating that it's not exported.

(I'd envision for example an interface with a single method ToOsInteger and that is implemented for those errors for which it makes sense to map to a Unix errno.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions