elsaland / elsa

❄️ Elsa is a minimal runtime for JavaScript and TypeScript written in Go
MIT License
2.8k stars 62 forks source link

Elsa functions don't throw exceptions for errors #75

Open samhza opened 4 years ago

samhza commented 4 years ago

Currently none of the Elsa functions (Elsa.stats, Elsa.readFile, etc) throw any exceptions in JS when they encounter errors, they instead print the error and exit with status code 1. There is no way to gracefully handle these errors from the JS code. These functions should throw exceptions instead of exiting so that the script (example below) can catch and handle them.

try {
  Elsa.stats("non-existent");
} catch (error) {
  console.error(error);
}