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

Cell level error handling #286

Open
ghost opened this issue Apr 12, 2021 · 3 comments
Open

Cell level error handling #286

ghost opened this issue Apr 12, 2021 · 3 comments
Labels
enhancement New feature or request question Further information is needed

Comments

@ghost
Copy link

ghost commented Apr 12, 2021

Hello,

When the evaluation of a cell throws an exception, the variable that was to be assigned the value becomes unavailable to subsequent calls, and all cells that reference that variables are now marked as error.

This is a problem when you have cases like this:

a = ... something that throws

b = ... something that doesn't throw

c = testThatsFalse ? a : b

It'd be better that c works.

I suggest that if the evaluation of a fails, a gets assigned an 'Error' type value, which can then be further processed. As in c = isError(a) ? b : a.

Happy to work on a PR if you think this could be a good idea.
This obviously would impact the way the minimap works, but I don't think there's a case where old notebooks would suffer from this change.
It's a one-way change though...

@mbostock
Copy link
Member

mbostock commented May 9, 2022

Adding a promiseof operator would be one way to allow error handling (as well as parallelism).

@ghost
Copy link
Author

ghost commented May 10, 2022

Just throwing my thoughts out here.

Having the users handle the promise is a little against what Observable usually does (taking care of promises). And it's going to be cumbersome as in 90% of cases, users will want to wrap the call that may fail in a try-await-promiseof-catch block that's unfortunately quite verbose.

Why not treat every variable references as promises to be awaited? ie. Making promiseof the general case rather than the special case? There may be implications around async generators I am not grasping though.

@tomlarkworthy
Copy link

Do you think we could consume events to avoid dataflow chaining (yet causing a cell to be observed still)

neverEmitEventsCell = {
    while (true) {
        await promiseof eventEmitterCell
    }
}

@mbostock mbostock added enhancement New feature or request question Further information is needed labels Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is needed
Projects
None yet
Development

No branches or pull requests

2 participants