Raise error if we get a non 200 status from fetch (#935)

* Raise error if we get a non 200 status from fetch

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add custom exception

* Add check for TypeError as well

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Fábio Rosado
2022-11-10 15:00:41 +00:00
committed by GitHub
parent 4c8443fd00
commit 3c3dffd5ed
4 changed files with 35 additions and 10 deletions

View File

@@ -210,8 +210,13 @@ export class PyScriptApp {
} catch (e) {
// Remove the loader so users can see the banner better
this.loader.remove()
//Should we still export full error contents to console?
handleFetchError(<Error>e, fetchPaths[i]);
// The 'TypeError' here happens when running pytest
// I'm not particularly happy with this solution.
if (e.name === "FetchError" || e.name === "TypeError") {
handleFetchError(<Error>e, fetchPaths[i]);
} else {
throw e
}
}
}
logger.info('All paths fetched');