Better request error handling

This commit is contained in:
Fabian 2016-10-15 01:16:18 +02:00
parent 5e9e1ca90d
commit 69e7927a96
2 changed files with 28 additions and 8 deletions

View file

@ -633,6 +633,14 @@
{
show_progress(e);
});
emulator.add_listener("download-error", function(e)
{
var el = $("loading");
el.style.display = "block";
el.textContent = "Loading " + e.file_name + " failed. Check your connection " +
"and reload the page to try again.";
});
};
/**

View file

@ -355,15 +355,27 @@ function V86Starter(options)
}.bind(this),
progress: function progress(e)
{
starter.emulator_bus.send("download-progress", {
file_index: index,
file_count: total,
file_name: f.url,
if(e.target.status === 200)
{
starter.emulator_bus.send("download-progress", {
file_index: index,
file_count: total,
file_name: f.url,
lengthComputable: e.lengthComputable,
total: e.total || f.size,
loaded: e.loaded,
});
lengthComputable: e.lengthComputable,
total: e.total || f.size,
loaded: e.loaded,
});
}
else
{
starter.emulator_bus.send("download-error", {
file_index: index,
file_count: total,
file_name: f.url,
request: e.target,
});
}
},
as_text: f.as_text,
});