noble-winrt icon indicating copy to clipboard operation
noble-winrt copied to clipboard

Improve error handling

Open geovie opened this issue 7 years ago • 0 comments

Currently we only log error in the noble-winrt package as noble has a rather bad error handling story (https://github.com/noble/noble/issues/830). The problem is that it only emits a warning if e.g. a peripheral is not found and there is no way for bindings to return an error.

A proper solution would be to add a error argument in the bindings interface and the noble interface to let bindings error bubble up to the user.

Noble.prototype.onDisconnect = function(peripheralUuid, error) {
  var peripheral = this._peripherals[peripheralUuid];
  if (peripheral) {
    peripheral.emit('disconnect', error);
  } else {
    this.emit('warning', 'unknown peripheral ' + peripheralUuid + ' disconnected!');
  }
};

geovie avatar Sep 28 '18 10:09 geovie