Skip to Content
Unpublished
Takes approximately 1 minute to read
Post History

My Experience Learning Python

Throwing Exceptions

In C#, we would have something like:

C#
code block
Skip
if (error) {
  throw new Exception("An error occured!");
}
Python
code block
Skip
if error:
    raise ValueError("An error occurred.")

Manually raising (throwing) an exception in Python - Stack Overflow