Reference: microsoft/go-winio#187 (comment)
In a unit test, I had code that checked an API call failure to detect missing privilege:
if errno, ok := errors.Cause(err).(syscall.Errno); ok && errno == syscall.ERROR_PRIVILEGE_NOT_HELD {
however, adapting it to use computestorage.FormatWritableLayerVhd, that no longer works, and I must use
if strings.Contains(err.Error(), "A required privilege is not held by the client.") {
This is because of the use of fmt.Errorf('...%s', err). If this is changed to errors.Wrapf(err, '...'), then I'd get the result I wanted.
I guess this was an oversight, since computerstorage/helpers.go does use errors.Wrapf and errors.Wrap.
However, I don't want to just put up a PR without discussion, if this was deliberately done to hide/obscure the underlying failure in these APIs.