lib: Wrap errors with errors.Wrap instead of fmt.Errorf (#6181)

This commit is contained in:
Simon Frei
2019-11-23 16:20:54 +01:00
committed by Audrius Butkevicius
parent e2f6d0d6c4
commit cf312abc72
7 changed files with 51 additions and 43 deletions

View File

@@ -10,7 +10,6 @@ package config
import (
"encoding/json"
"encoding/xml"
"errors"
"fmt"
"io"
"io/ioutil"
@@ -22,6 +21,8 @@ import (
"strconv"
"strings"
"github.com/pkg/errors"
"github.com/syncthing/syncthing/lib/fs"
"github.com/syncthing/syncthing/lib/protocol"
"github.com/syncthing/syncthing/lib/rand"
@@ -120,13 +121,13 @@ func NewWithFreePorts(myID protocol.DeviceID) (Configuration, error) {
port, err := getFreePort("127.0.0.1", DefaultGUIPort)
if err != nil {
return Configuration{}, fmt.Errorf("get free port (GUI): %v", err)
return Configuration{}, errors.Wrap(err, "get free port (GUI)")
}
cfg.GUI.RawAddress = fmt.Sprintf("127.0.0.1:%d", port)
port, err = getFreePort("0.0.0.0", DefaultTCPPort)
if err != nil {
return Configuration{}, fmt.Errorf("get free port (BEP): %v", err)
return Configuration{}, errors.Wrap(err, "get free port (BEP)")
}
if port == DefaultTCPPort {
cfg.Options.ListenAddresses = []string{"default"}