all: Modernize error wrapping (#8491)

This replaces old style errors.Wrap with modern fmt.Errorf and removes
the (direct) dependency on github.com/pkg/errors. A couple of cases are
adjusted by hand as previously errors.Wrap(nil, ...) would return nil,
which is not what fmt.Errorf does.
This commit is contained in:
Jakob Borg
2022-08-16 10:01:49 +02:00
committed by GitHub
parent 75eeae0ee7
commit b10d106a55
23 changed files with 108 additions and 109 deletions
+7 -4
View File
@@ -7,7 +7,8 @@
package osutil
import (
"github.com/pkg/errors"
"fmt"
"golang.org/x/sys/windows"
)
@@ -16,10 +17,12 @@ import (
func SetLowPriority() error {
handle, err := windows.GetCurrentProcess()
if err != nil {
return errors.Wrap(err, "get process handle")
return fmt.Errorf("get process handle: %w", err)
}
defer windows.CloseHandle(handle)
err = windows.SetPriorityClass(handle, windows.BELOW_NORMAL_PRIORITY_CLASS)
return errors.Wrap(err, "set priority class") // wraps nil as nil
if err := windows.SetPriorityClass(handle, windows.BELOW_NORMAL_PRIORITY_CLASS); err != nil {
return fmt.Errorf("set priority class: %w", err)
}
return nil
}