all: Get rid of fatal logging (#5537)
* cleanup Fatal in lib/config/config.go * cleanup Fatal in lib/config/folderconfiguration.go * cleanup Fatal in lib/model/model.go * cleanup Fatal in cmd/syncthing/monitor.go * cleanup Fatal in cmd/syncthing/main.go * cleanup Fatal in lib/api * remove Fatal methods from logger * lowercase in errors.Wrap * one less channel
This commit is contained in:
committed by
Audrius Butkevicius
parent
7a40c42e8b
commit
d5ff2c41dc
@@ -84,18 +84,18 @@ func New(myID protocol.DeviceID) Configuration {
|
||||
return cfg
|
||||
}
|
||||
|
||||
func NewWithFreePorts(myID protocol.DeviceID) Configuration {
|
||||
func NewWithFreePorts(myID protocol.DeviceID) (Configuration, error) {
|
||||
cfg := New(myID)
|
||||
|
||||
port, err := getFreePort("127.0.0.1", DefaultGUIPort)
|
||||
if err != nil {
|
||||
l.Fatalln("get free port (GUI):", err)
|
||||
return Configuration{}, fmt.Errorf("get free port (GUI): %v", err)
|
||||
}
|
||||
cfg.GUI.RawAddress = fmt.Sprintf("127.0.0.1:%d", port)
|
||||
|
||||
port, err = getFreePort("0.0.0.0", DefaultTCPPort)
|
||||
if err != nil {
|
||||
l.Fatalln("get free port (BEP):", err)
|
||||
return Configuration{}, fmt.Errorf("get free port (BEP): %v", err)
|
||||
}
|
||||
if port == DefaultTCPPort {
|
||||
cfg.Options.ListenAddresses = []string{"default"}
|
||||
@@ -106,7 +106,7 @@ func NewWithFreePorts(myID protocol.DeviceID) Configuration {
|
||||
}
|
||||
}
|
||||
|
||||
return cfg
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
func ReadXML(r io.Reader, myID protocol.DeviceID) (Configuration, error) {
|
||||
|
||||
@@ -106,7 +106,7 @@ func (f FolderConfiguration) Versioner() versioner.Versioner {
|
||||
}
|
||||
versionerFactory, ok := versioner.Factories[f.Versioning.Type]
|
||||
if !ok {
|
||||
l.Fatalf("Requested versioning type %q that does not exist", f.Versioning.Type)
|
||||
panic(fmt.Sprintf("Requested versioning type %q that does not exist", f.Versioning.Type))
|
||||
}
|
||||
|
||||
return versionerFactory(f.ID, f.Filesystem(), f.Versioning.Params)
|
||||
|
||||
Reference in New Issue
Block a user