platforms/joystick: wrap loadfile error to more easily handle OS differences

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2023-09-12 12:09:56 +02:00
parent 2a352ed250
commit 7ed78ccb4b
2 changed files with 3 additions and 3 deletions

View File

@ -177,7 +177,7 @@ func (j *Driver) initConfig() error {
default:
err := j.loadFile()
if err != nil {
return err
return fmt.Errorf("loadfile error: %w", err)
}
}

View File

@ -56,7 +56,7 @@ func TestDriverHandleEvent(t *testing.T) {
if err := d.initConfig(); err != nil {
t.Errorf("initConfig() error: %v", err)
}
d.initEvents()
// left x stick
@ -106,5 +106,5 @@ func TestDriverHandleEvent(t *testing.T) {
func TestDriverInvalidConfig(t *testing.T) {
d, _ := initTestDriver("./configs/doesnotexist")
err := d.Start()
gobottest.Assert(t, strings.Contains(err.Error(), "open ./configs/doesnotexist: no such file or directory"), true)
gobottest.Assert(t, strings.Contains(err.Error(), "loadfile error"), true)
}