From 316d1ad38405bd421c4d8c4d66264584d464832f Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Mon, 11 Feb 2019 19:15:38 +0100 Subject: Updated error handling --- public/scripts/chat.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'public/scripts/chat.js') diff --git a/public/scripts/chat.js b/public/scripts/chat.js index c875698..fa70606 100644 --- a/public/scripts/chat.js +++ b/public/scripts/chat.js @@ -94,7 +94,11 @@ function chat() { }); peer.on('error', err => { console.error(err); - swal('Connection lost!', '', 'error'); + if (err.type === 'network') swal('Connection to server lost!', '', 'error'); + else if (err.type === 'browser-incompatible') swal('Your server is not compatible!', 'Please update or use another browser!', 'error'); + else if (err.type === 'peer-unavailable') swal('Peer could not be found!', '', 'error'); + else if (err.type === 'unavailable-id') swal('Ou snap! Your ID isn\'t available!', '', 'error'); + else swal('Unhandled Error!', 'You just threw up this error: ' + err.type, 'error'); }); peer.on('connection', async conn => { connectedPeer = conn; -- cgit v1.2.3