[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 6/9] golang/xenlight: Errors are negative



On Fri, Dec 27, 2019 at 11:33 AM George Dunlap <george.dunlap@xxxxxxxxxx> wrote:
>
> Commit 871e51d2d4 changed the sign on the xenlight error types (making
> the values negative, same as the C-generated constants), but failed to
> flip the sign in the Error() string function.  The result is that
> ErrorNonspecific.String() prints "libxl error: 1" rather than the
> human-readable error message.

Since we're here, what would you think about re-defining libxlErrors
as a map[Error]string? That way, Error() can just be:

func (e Error) Error() string {
        if s, ok := libxlErrors[e]; ok {
                return s
        }

        return fmt.Sprintf("libxl error: %d", e)
}

I think it's less error-prone and easier to read. Thoughts?

-NR

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.