Using the twilio nodejs api crashes node when an error is thrown. For example if the room already exists..
/home/web/node_modules/twilio/node_modules/q/q.js:876 throw error; Error: Room exists
Try catch does not help. Tried wrapping it in a promise, no luck. Tried to first fetch the room, but it crashes in the same way if the room does not exist. Tried to retrieve a list of all in-progress rooms, but it stalls forever. I can get a list of all completed rooms but I need to check in-progress ones. Either way crashing node is no good, need to be able to handle these eventualities.
exports.createBackendRoom = function (roomname, callback) {
try {
client.video.rooms.create({uniqueName: roomname})
.then(function(room) {
console.log(room);
callback(true);
}).done();
} catch(e) {
console.log(e);
callback(false);
}
}
Unable to handle the errors..
/home/web/node_modules/twilio/node_modules/q/q.js:876 throw error; Error: Room exists
How can I gracefully handle these?
callback(true)
on error and handle the error on the other ways – mandaputtra