Skip to content

Commit 41bf5dd

Browse files
committed
Improve error messages for common cases
#11 #12
1 parent 9b56b6a commit 41bf5dd

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

unpackager.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,25 @@ var unpackage = (function() {
425425
};
426426
}
427427

428+
// At this point, we couldn't find any data in the file.
429+
// Let's try to generate more useful error messages for some common intended failure cases.
430+
431+
// If the file depends on "script.js" then it was packaged by TurboWarp Packager as a zip
432+
// and so it cannot be unpackaged with just the HTML file.
433+
if (text.includes('<script src="script.js"></script>')) {
434+
throw new Error('It looks like the project was packaged as a zip, but only the HTML file was provided. Open an issue including the URL where you got this file and we will manually unpackage it for you. This is a manual process for now.');
435+
}
436+
437+
// Look for various hints that this is an export of the HTML after the project has loaded.
438+
if (
439+
text.includes('<div class="sc-layers"') ||
440+
text.includes('<canvas class="sc-canvas"') ||
441+
text.includes('<div class="scratch-render-overlays"') ||
442+
text.includes('<div class="sc-monitor-overlay"')
443+
) {
444+
throw new Error('It looks like you saved the HTML after the project loads. This does not work as the project data is removed from the HTML as the project loads to save memory. Open an issue including the URL where you got this file and we will manually unpackage it for you. This is a manual process for now.');
445+
}
446+
428447
throw new Error('Input was not a zip and we could not find project.');
429448
};
430449

0 commit comments

Comments
 (0)