thalmiclabs / myo.js

Myo javascript bindings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please add option to override the onError handler

derwaldgeist opened this issue · comments

We are building an application that supports many different gesture input devices. As the user does not necessarily have a Myo band, connecting to Myo Connect may fail.

In this case, the library throws an error which is not easy to catch, since it is thrown async. In my case, this caused the EventEmitter of ws to fail, and it was quite hard to track down the source of this problem.

For the time being, I'm working around this by manually overwriting Myo.onError, but it would be better if there was a way to explicitly call Myo.on('error', fn).

PS: The current behaviour of throwing in case of an error is not a good idea. It's not possible to catch this in a regular try catch due to its async behaviour. It would be better if just an error messages would be printed on the console.