Improve error handling and reporting for server installation & process boot

This commit is contained in:
Dane Everitt
2021-03-03 20:56:18 -08:00
parent 33f5cb7df4
commit 0919fb2da6
7 changed files with 38 additions and 29 deletions

View File

@@ -70,8 +70,8 @@ type Server struct {
wsBagLocker sync.Mutex
}
// Returns a new server instance with a context and all of the default values set on
// the instance.
// New returns a new server instance with a context and all of the default
// values set on the struct.
func New(client remote.Client) (*Server, error) {
ctx, cancel := context.WithCancel(context.Background())
s := Server{
@@ -82,16 +82,16 @@ func New(client remote.Client) (*Server, error) {
transferring: system.NewAtomicBool(false),
}
if err := defaults.Set(&s); err != nil {
return nil, err
return nil, errors.Wrap(err, "server: could not set default values for struct")
}
if err := defaults.Set(&s.cfg); err != nil {
return nil, err
return nil, errors.Wrap(err, "server: could not set defaults for server configuration")
}
s.resources.State = system.NewAtomicString(environment.ProcessOfflineState)
return &s, nil
}
// Returns the UUID for the server instance.
// Id returns the UUID for the server instance.
func (s *Server) Id() string {
return s.Config().GetUuid()
}