From 645e47bd7260ac7b004fec01bdf1176f3285761a Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 13 Mar 2018 15:10:33 +0100 Subject: [PATCH] Catch chainpad errors in polls --- www/poll/inner.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/www/poll/inner.js b/www/poll/inner.js index a6e9b8bd8..9222d90a0 100644 --- a/www/poll/inner.js +++ b/www/poll/inner.js @@ -1106,6 +1106,25 @@ define([ } }; + var onError = function (info) { + if (info && info.type) { + if (info.type === 'CHAINPAD') { + APP.unrecoverable = true; + setEditable(false); + APP.toolbar.errorState(true, info.error); + var msg = Messages.chainpadError; + UI.errorLoadingScreen(msg, true, true); + console.error(info.error); + return; + } + // Server error + return void common.onServerError(info, APP.toolbar, function () { + APP.unrecoverable = true; + setEditable(false); + }); + } + }; + // Manage disconnections because of network or error var onDisconnect = function (info) { if (APP.unrecoverable) { return; } @@ -1318,7 +1337,8 @@ define([ }); }) .on('disconnect', onDisconnect) - .on('reconnect', onReconnect); + .on('reconnect', onReconnect) + .on('error', onError); }); }; main();