mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-21 03:05:38 -05:00
use emscripten virtual FS directly to load paths (#870)
* use emscripten virtual FS directly to load paths * use more low level APIs * use await instead of then * remove try...catch from loadFromFile since it's being handled externally * add test for an invalid path * test checks for error shown to the user too * add comment about a missing case
This commit is contained in:
@@ -64,9 +64,11 @@ export function showError(msg: string): void {
|
||||
|
||||
export function handleFetchError(e: Error, singleFile: string) {
|
||||
//Should we still export full error contents to console?
|
||||
console.warn(`Caught an error in loadPaths:\r\n ${e.toString()}`);
|
||||
// XXX: What happens if I make a typo? i.e. a web server is being used but a file
|
||||
// that doesn't exist is being accessed. We should cover this case as well.
|
||||
console.warn(`Caught an error in fetchPaths:\r\n ${e.toString()}`);
|
||||
let errorContent: string;
|
||||
if (e.message.includes('TypeError: Failed to fetch')) {
|
||||
if (e.message.includes('Failed to fetch')) {
|
||||
errorContent = `<p>PyScript: Access to local files
|
||||
(using "Paths:" in <py-config>)
|
||||
is not available when directly opening a HTML file;
|
||||
|
||||
Reference in New Issue
Block a user