diff --git a/editor.html b/editor.html
index 0045f024..5ab12b0a 100644
--- a/editor.html
+++ b/editor.html
@@ -321,6 +321,7 @@
{{ title }}
'download': 'Safari has a bug that means your work will be downloaded as an un-named file. Please rename it to something ending in .hex. Alternatively, use a browser such as Firefox or Chrome. They do not suffer from this bug.',
'save': 'Safari has a bug that means your work will be downloaded as an un-named file. Please rename it to something ending in .py. Alternatively, use a browser such as Firefox or Chrome. They do not suffer from this bug.',
'length': 'Oops! Your script is too long given the limited memory on the device.',
+ 'unrecognised_hex': "Sorry, we couldn't recognise this file",
'snippets': 'Snippets are disabled when blockly is enabled.'
},
'confirms': {
diff --git a/python-main.js b/python-main.js
index 91f937af..32a7db8e 100644
--- a/python-main.js
+++ b/python-main.js
@@ -402,9 +402,16 @@ function web_editor(config) {
setName(f.name.replace('.hex', ''));
setDescription(config.translate.drop.hex);
reader.onload = function(e) {
- var code = upyhex.extractPyStrFromIntelHex(
- e.target.result);
- if(code.length < 8192) {
+ var code = '';
+ var showAlert = false;
+ try {
+ code = upyhex.extractPyStrFromIntelHex(e.target.result);
+ } catch(e) {
+ showAlert = true;
+ }
+ if (showAlert || code.length === 0) {
+ return alert(config.translate.alerts.unrecognised_hex);
+ } else {
EDITOR.setCode(code);
}
};
@@ -579,8 +586,16 @@ function web_editor(config) {
setName(file.name.replace('.hex', ''));
setDescription(config.translate.drop.hex);
reader.onload = function(e) {
- var code = upyhex.extractPyStrFromIntelHex(e.target.result);
- if (code.length < 8192) {
+ var code = '';
+ var showAlert = false;
+ try {
+ code = upyhex.extractPyStrFromIntelHex(e.target.result);
+ } catch(e) {
+ showAlert = true;
+ }
+ if (showAlert || code.length === 0) {
+ return alert(config.translate.alerts.unrecognised_hex);
+ } else {
EDITOR.setCode(code);
}
};