Skip to content

Commit

Permalink
handle file errors correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
mnater committed May 26, 2018
1 parent 3ea2e77 commit 1c7b0b6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions hyphenopoly.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ function loadWasm() {
`${Hyphenopoly.c.paths.maindir}hyphenEngine.wasm`,
function cb(err, data) {
if (err) {
// Handle load error
Hyphenopoly.events.dispatch("error", {
"msg": `${Hyphenopoly.c.paths.maindir}hyphenEngine.wasm not found.`
});
} else {
Hyphenopoly.binaries.hyphenEngine = new Uint8Array(data).buffer;
Hyphenopoly.events.dispatch("engineLoaded");
Expand All @@ -131,7 +133,10 @@ function loadHpb(lang) {
`${Hyphenopoly.c.paths.patterndir}${lang}.hpb`,
function cb(err, data) {
if (err) {
// Handle load error
Hyphenopoly.events.dispatch("error", {
"msg": `${Hyphenopoly.c.paths.patterndir}${lang}.hpb not found.`,
"lang": lang
});
} else {
Hyphenopoly.binaries[lang] = new Uint8Array(data).buffer;
Hyphenopoly.events.dispatch("hpbLoaded", {"msg": lang});
Expand Down Expand Up @@ -609,7 +614,10 @@ Hyphenopoly.config = function config(userConfig) {
}
});
Hyphenopoly.events.addListener("error", function handler(e) {
reject(e.msg);
e.preventDefault();
if (e.lang === lang) {
reject(e.msg);
}
});
});
result.set(lang, prom);
Expand Down Expand Up @@ -641,7 +649,7 @@ Hyphenopoly.config = function config(userConfig) {
define(
"error",
function def(e) {
window.console.error(e.msg);
console.error(e.msg);
},
true
);
Expand Down

0 comments on commit 1c7b0b6

Please sign in to comment.