Return task object including fault details in case of fault. Return reason for connection request failure.
This commit is contained in:
1 parent
907d13606c
commit
2cf31935bc
2 files changed
+29
-10
No files matched your search
@@ -130,15 +130,19 @@ connectionRequest = (deviceId, callback) ->
|
||||
|
||||
watchTask = (taskId, timeout, callback) ->
|
||||
setTimeout( () ->
|
||||
db.tasksCollection.findOne({_id : taskId}, {'_id' : 1}, (err, task) ->
|
||||
db.tasksCollection.findOne({_id : taskId}, {'_id' : 1, 'fault' : 1}, (err, task) ->
|
||||
return callback(err) if err
|
||||
|
||||
if task
|
||||
timeout -= 500
|
||||
if timeout < 0
|
||||
callback(new Error('Timeout'))
|
||||
if task.fault?
|
||||
callback(null, 'fault')
|
||||
else if timeout <= 0
|
||||
callback(null, 'timeout')
|
||||
else
|
||||
watchTask(taskId, timeout, callback)
|
||||
else
|
||||
callback(err)
|
||||
callback(null, 'completed')
|
||||
)
|
||||
, 500)
|
||||
|
||||
|
||||
Reference in new issue
Block a user