sketch-sh icon indicating copy to clipboard operation
sketch-sh copied to clipboard

Continue evaluating other codeblocks even if a fatal error was thrown

Open thangngoc89 opened this issue 7 years ago • 5 comments

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 avatar Aug 26 '18 15:08 thangngoc89

another example in the wild:

image

thangngoc89 avatar Aug 26 '18 15:08 thangngoc89

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.

hcarty avatar Aug 26 '18 15:08 hcarty

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

thangngoc89 avatar Aug 26 '18 15:08 thangngoc89

  • octachron on Discord:

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

thangngoc89 avatar Aug 26 '18 15:08 thangngoc89

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 https://github.com/Sketch-sh/sketch-sh/blob/fd75d692784bb21a55575eb94343b8928fcddfba/client/src_analyzer/Worker_Analyze.re#L103-L104 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 https://github.com/Sketch-sh/sketch-sh/blob/fd75d692784bb21a55575eb94343b8928fcddfba/client/src_editor/Editor_Blocks.re#L241-L255

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

thangngoc89 avatar Aug 31 '18 14:08 thangngoc89