Skip to content

Error handling #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
adam-mcdaniel opened this issue Oct 18, 2021 · 1 comment
Open

Error handling #68

adam-mcdaniel opened this issue Oct 18, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@adam-mcdaniel
Copy link
Owner

adam-mcdaniel commented Oct 18, 2021

When I'm not connected to the internet, curl fails to get weather data which causes parse@json to fail, and also terminates the execution of my prelude early. I think that we should try to make a convenient way to handle errors (although the parsing functions should be implemented such that they return None instead of throwing errors).

I'm thinking of implementing a try builtin function that might behave like the following:

try 2 // 0 { echo "divide by zero"; 0 }

try would attempt to evaluate the first argument If it does not throw an error, then try will return that result. If the first argument fails to evaluate, it would evaluate the second argument, and return its result.

@adam-mcdaniel adam-mcdaniel added the enhancement New feature or request label Oct 18, 2021
@Aloso
Copy link
Contributor

Aloso commented Oct 18, 2021

I'd prefer a syntax where the exception is available as a variable, for example:

try 2 // 0
catch e -> { echo e@message; 0 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants