mirror of
https://github.com/safing/portmaster
synced 2025-09-01 01:59:11 +00:00
Add error-handling for WindowsVersion-stuff
This commit is contained in:
parent
0a5981c657
commit
6867a9b174
3 changed files with 33 additions and 1 deletions
10
core/core.go
10
core/core.go
|
@ -1,11 +1,19 @@
|
|||
package core
|
||||
|
||||
import "github.com/safing/portbase/modules"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/safing/portbase/modules"
|
||||
)
|
||||
|
||||
var (
|
||||
coreModule = modules.Register("core", nil, startCore, nil, "base", "database", "config", "api", "random")
|
||||
)
|
||||
|
||||
func startCore() error {
|
||||
if err := startPlatformSpecific(); err != nil {
|
||||
return fmt.Errorf("failed to start plattform-specific stuff: %s", err)
|
||||
}
|
||||
|
||||
return registerDatabases()
|
||||
}
|
||||
|
|
8
core/os_default.go
Normal file
8
core/os_default.go
Normal file
|
@ -0,0 +1,8 @@
|
|||
// +build !windows
|
||||
|
||||
package core
|
||||
|
||||
// only return on Fatal error!
|
||||
func startPlatformSpecific() error {
|
||||
return nil
|
||||
}
|
16
core/os_windows.go
Normal file
16
core/os_windows.go
Normal file
|
@ -0,0 +1,16 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"github.com/safing/portbase/log"
|
||||
"github.com/safing/portbase/utils/osdetail"
|
||||
)
|
||||
|
||||
// only return on Fatal error!
|
||||
func startPlatformSpecific() error {
|
||||
// We can't catch errors when calling WindowsNTVersion() in logging, so we call the function here, just to catch possible errors
|
||||
if _, err := osdetail.WindowsNTVersion(); err != nil {
|
||||
log.Errorf("failed to obtain WindowsNTVersion: %s", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Loading…
Add table
Reference in a new issue