core: use multierror when handling Robot Stop

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2016-12-01 20:40:11 +01:00
parent 5e56638018
commit 0764500955
1 changed files with 11 additions and 3 deletions

View File

@ -185,12 +185,20 @@ func (r *Robot) Start(args ...interface{}) (err error) {
}
// Stop stops a Robot's connections and Devices
func (r *Robot) Stop() (err error) {
func (r *Robot) Stop() error {
var result error
log.Println("Stopping Robot", r.Name, "...")
err = r.Devices().Halt()
err := r.Devices().Halt()
if err != nil {
result = multierror.Append(result, err)
}
err = r.Connections().Finalize()
if err != nil {
result = multierror.Append(result, err)
}
r.done <- true
return err
return result
}
// Devices returns all devices associated with this Robot.