Skip to content
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

Continue evaluating other codeblocks even if a fatal error was thrown #143

Open
thangngoc89 opened this issue Aug 26, 2018 · 5 comments
Open
Labels
good first issue Good for newcomers

Comments

@thangngoc89
Copy link
Member

thangngoc89 commented Aug 26, 2018

In education sketches like this one, the author sometimes wants to explicitly throw an error

image

and continue to explain the idea below. Maybe we should continue evaluating other codeblocks?

@thangngoc89
Copy link
Member Author

another example in the wild:

image

@hcarty
Copy link

hcarty commented Aug 26, 2018

Maybe it's worth adding a "skip" option for code blocks? It could be something that only shows up when a block fails to evaluate.

@thangngoc89
Copy link
Member Author

@hcarty I see. That's an interesting idea. I'll explore that route to see how complicated it's to implement

@thangngoc89
Copy link
Member Author

thangngoc89 commented Aug 26, 2018

  • octachron on Discord:

For a similar purpose, the manual example generator uses an attribute when a error is expected ([@expect error])

@thangngoc89 thangngoc89 added the good first issue Good for newcomers label Aug 31, 2018
@thangngoc89
Copy link
Member Author

Let's go with the approach of adding an option to the block to say that this block is expecting to fail. And probably we should only display the option when there is an error.

Details:

  • This is the condition in worker thread
    hasError ?
    [(id, result), ...acc] : loop(rest, [(id, result), ...acc]);
    to stop executing when there is an error. We can easily add an option there to keep evaluating other blocks.
  • This is where the the code blocks is gathered and send to worker thread
    let allCodeToExecute =
    state.blocks
    ->(
    Belt.Array.reduceU([], (. acc, {b_id, b_data, b_deleted}) =>
    b_deleted ?
    acc :
    (
    switch (b_data) {
    | B_Text(_) => acc
    | B_Code({bc_value}) => [(b_id, bc_value), ...acc]
    }
    )
    )
    )
    ->Belt.List.reverse;

You can put the expect to fail condition there before sending to worker

@thangngoc89 thangngoc89 changed the title [RFC] Continue evaluating other codeblocks even if a fatal error was thrown Continue evaluating other codeblocks even if a fatal error was thrown Aug 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants