Trap more errors.

This commit is contained in:
Simo Kinnunen
2014-01-29 16:47:25 +09:00
parent ae4e4d3075
commit a8914297ad

View File

@@ -35,6 +35,12 @@ module.exports = function(options) {
// Show serial number in logs
logger.setGlobalIdentifier(options.serial)
// Panic if necessary
Promise.onPossiblyUnhandledRejection(function(err, promise) {
log.fatal('Unhandled rejection', err.stack)
selfDestruct()
})
// Adb
var adb = Promise.promisifyAll(adbkit.createClient())
@@ -210,10 +216,14 @@ module.exports = function(options) {
})
})
})
.done(function() {
.then(function() {
log.info('Ready for instructions')
poke()
})
.catch(function(err) {
log.fatal('Setup failed', err.stack)
selfDestruct()
})
sub.on('message', function(channel, data) {
var wrapper = wire.Envelope.decode(data)