aboutsummaryrefslogtreecommitdiffhomepage
path: root/public
diff options
context:
space:
mode:
authorMarvin Borner2019-02-11 19:15:38 +0100
committerMarvin Borner2019-02-11 19:15:38 +0100
commit316d1ad38405bd421c4d8c4d66264584d464832f (patch)
tree64818ccbe3f275d1e26e1fed34f67c94d26c2685 /public
parent569d320d2f596f58f201ab0d6a1e4ff456e99dfe (diff)
Updated error handling
Diffstat (limited to 'public')
-rw-r--r--public/scripts/chat.js6
-rw-r--r--public/scripts/encryption.js5
2 files changed, 9 insertions, 2 deletions
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;
diff --git a/public/scripts/encryption.js b/public/scripts/encryption.js
index 74abddc..fc5665b 100644
--- a/public/scripts/encryption.js
+++ b/public/scripts/encryption.js
@@ -9,6 +9,7 @@ const Dexie = require('dexie');
const moment = require('moment');
const crypto = require('crypto');
const openpgp = require('openpgp');
+const swal = require('sweetalert');
// compress encryption data
openpgp.config.compression = openpgp.enums.compression.zlib;
@@ -32,6 +33,7 @@ function setupDatabase() {
db.open().catch(e => {
localStorage.setItem('database', 'failed');
console.error("Database failed: " + e.stack);
+ swal('Could not create the local database!', 'Please try loading this site from a different browser', 'error');
});
window.db = db;
@@ -235,7 +237,8 @@ async function getPeerPublicKey(peerId) {
const publicKeyUserId = await getPublicKeyUserId(publicKey);
if (publicKeyUserId !== peerId) {
publicKey = '';
- console.error('[LOG] Public key verification failed! The peers real identity is ' + publicKeyUserId)
+ console.error('[LOG] Public key verification failed! The peers real identity is ' + publicKeyUserId);
+ swal('There\'s something strange going on here!', 'The peers ID could not be verified! His real ID is ' + publicKeyUserId, 'error');
} else
console.log('[LOG] Public key verification succeeded!')
} else