Python Chunks: Stop on Error in Rstudio Notebook

I am working in an Rmarkdown notebook where I am trying to get python code chunks to stop when I raise an error, which I can achieve in R code chunks. I haven't been able to find a setting that allows me to do this, so I am wondering if it's at all possible?

Below is a super simple example of the code I am running.

title: "R Notebook"
output: html_notebook

This R chunk is well behaved

x = -1

if (x < 0)
  stop("Sorry, no numbers below zero")

print("The error stops me from being evaluated :( ")

This python chunk should raise an error and not print anything.

x = -1

if x < 0:
  raise Exception("Sorry, no numbers below zero")

print("I am still being evaluated despite the error!")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.