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

build crashes if a cell errors #73

Closed
rkurchin opened this issue Feb 16, 2022 · 4 comments
Closed

build crashes if a cell errors #73

rkurchin opened this issue Feb 16, 2022 · 4 comments

Comments

@rkurchin
Copy link

rkurchin commented Feb 16, 2022

Thanks for an awesome package, this is perfect for integrating code into my docs site, and way less fiddly than trying to do everything with doctests.

I'm using this to make a tutorial/demo for how to use my package and I was hoping to show how a particular thing throws an error and how to do it correctly, but it seems that as soon as an error is thrown in the evaluation, the build stops rather than finishing. Is there a way to force it to forge ahead anyway?

(For the moment I've just put that cell inside a try-catch and then @show the caught error which is a reasonable interim solution, but does look slightly clunkier - point being this is by no means an urgent thing to address)

@rikhuijzer
Copy link
Owner

rikhuijzer commented Feb 16, 2022

Thanks for an awesome package, this is perfect for integrating code into my docs site, and way less fiddly than trying to do everything with doctests.

Exactly my thoughts! Thank you for trying it out! 😄

I'm using this to make a tutorial/demo for how to use my package and I was hoping to show how a particular thing throws an error and how to do it correctly, but it seems that as soon as an error is thrown in the evaluation, the build stops rather than finishing. Is there a way to force it to forge ahead anyway?

(For the moment I've just put that cell inside a try-catch and then @show the caught error which is a reasonable interim solution, but does look slightly clunkier - point being this is by no means an urgent thing to address)

I think that that is also what I would do. To hide the clunkiness from the reader, you can maybe use # hide comments at the end of lines that aren't interesting to the reader. Would that work? I've experimented a bit and this should work:

"Helper function to show error and stacktrace to the reader."
function error_and_stacktrace(e::Exception)
    trace = sprint(io -> Base.show_backtrace(io, backtrace()))
    err = sprint(showerror, e)
    return string(err, trace) |> Base.Text
end
try # hide 
sum(1, 2)
catch e # hide
    error_and_stacktrace(e) # hide
end # hide

image

@rkurchin
Copy link
Author

Ahh cool, didn't know about the # hide comment trick, thanks!

@rikhuijzer
Copy link
Owner

You're welcome

Can this issue be closed? 🙂

@rkurchin
Copy link
Author

Oh yeah, go ahead – sorry for delay replying to this!

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

No branches or pull requests

2 participants