From 7087884831cc06e511be1dacef3588ca94b6de7c Mon Sep 17 00:00:00 2001 From: Rahbari Guillaume Date: Sun, 17 Jan 2016 14:05:27 +0100 Subject: [PATCH] Handle error when the connecttion to the sphero fail --- lib/adaptors/serialport.js | 2 ++ lib/sphero.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/adaptors/serialport.js b/lib/adaptors/serialport.js index b928147..e0b0f21 100644 --- a/lib/adaptors/serialport.js +++ b/lib/adaptors/serialport.js @@ -72,6 +72,8 @@ Adaptor.prototype.open = function open(callback) { callback(); }); + + port.on("error", emit("error")); }; /** diff --git a/lib/sphero.js b/lib/sphero.js index f7f41ae..f16a80b 100644 --- a/lib/sphero.js +++ b/lib/sphero.js @@ -92,6 +92,8 @@ Sphero.prototype.connect = function(callback) { connection.on("open", emit("open")); + connection.on("error", emit("error")); + connection.open(function() { self.ready = true;