proposal: x/sys/windows: let HRESULT
implement the error
interface
#57278
Labels
Milestone
HRESULT
implement the error
interface
#57278
Now error values from APIs in the x/sys/windows package are
syscall.Errno
, even though the original API returnsHRESULT
value. For example,CoInitializeEx
originally returnsHRESULT
, butwindows.CoInitializeEx
wraps the HRESULT value assyscall.Errno
and returns it. This package doesn't distinguishErrno
andHRESULT
as error values, and this seems odd in terms of semantics. My understanding isErrno
andHRESULT
are different things. There might be a historical reason why this package does so, but in this case I'd like to know.My proposal is to let
HRESULT
implement theerror
interface and let the APIs return it (when the value is notS_OK
) instead of wrapping asErrno
. This simple implementation would be enough:This is a breaking change and existing error checkings might no longer work, after the APIs return
HRESULT
instead ofErrno
. However, as x/sys/windows is still v0, a breaking change should be acceptable.The controversial point is that there are some non-zero values which can be used in a successful case (e.g.
S_FALSE
forCoInitializeEx
). In this case, implementingerror
might be odd. IMO my proposal is not a perfect solution but should be better than wrappingHRESULT
asErrno
without conditions, and improve the current semantics confusion.The text was updated successfully, but these errors were encountered: