Improve error handling in worker

This commit is contained in:
RunasSudo 2017-12-11 20:47:32 +10:30
parent d71e9e4821
commit 36cb4defe2
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
2 changed files with 20 additions and 13 deletions

View File

@ -31,7 +31,7 @@ for f in eos.js_tests; do
perl -0777 -pi -e 's/__except0__.__cause__ = null;//g' eos/__javascript__/$f.js
# Fix handling of properties, Transcrypt bug #407
perl -077 -pi -e 's/var __get__ = function \(self, func, quotedFuncName\) \{/var __get__ = function (self, func, quotedFuncName) { if(typeof(func) != "function"){return func;}/g' eos/__javascript__/$f.js
perl -0777 -pi -e 's/var __get__ = function \(self, func, quotedFuncName\) \{/var __get__ = function (self, func, quotedFuncName) { if(typeof(func) != "function"){return func;}/g' eos/__javascript__/$f.js
perl -0777 -pi -e 's/property.call \((.*?), \g1.\g1.__impl__(.*?)\)/property.call ($1, $1.__impl__$2)/g' eos/__javascript__/$f.js
perl -0777 -pi -e 's/property.call \((.*?), \g1.\g1.__implpy_(.*?)\)/property.call ($1, $1.__impl__$2)/g' eos/__javascript__/$f.js
done

View File

@ -34,18 +34,25 @@ function generateEncryptedVote(election, answers, should_do_fingerprint) {
}
onmessage = function(msg) {
if (!isLibrariesLoaded) {
importScripts(
msg.data.static_base_url + "js/eosjs.js"
);
isLibrariesLoaded = true;
}
try {
if (!isLibrariesLoaded) {
importScripts(
msg.data.static_base_url + "js/eosjs.js"
);
isLibrariesLoaded = true;
}
if (msg.data.action === "generateEncryptedVote") {
msg.data.election = eosjs.eos.core.objects.__all__.EosObject.deserialise_and_unwrap(msg.data.election, null);
if (msg.data.action === "generateEncryptedVote") {
msg.data.election = eosjs.eos.core.objects.__all__.EosObject.deserialise_and_unwrap(msg.data.election, null);
generateEncryptedVote(msg.data.election, msg.data.answers);
} else {
throw "Unknown action: " + msg.data.action;
generateEncryptedVote(msg.data.election, msg.data.answers);
} else {
throw "Unknown action: " + msg.data.action;
}
} catch (ex) {
if (ex.__repr__) {
throw ex.__repr__();
}
throw ex;
}
}