Hi I'm trying to figure out the way to trigger action - stop a program from running IF it's var value got populated.
class Checker:
def __init__(self, value):
self.value = value
self.error = None
self.check1() # I'd like to stop run after any of checks IF self.error is populated
self.check2() # But I want to do it without explicitly stating 'if self.error: return' after each check.
self.check3() # Basically, I'm looking for a trigger that will initiate return to break flow as soon as self.error gets populated.
self.is_valid = not self.error
def check1(self):
if condition:
self.error = "Found error1"
def check2(self):
if condition:
self.error = "Found error2"
def check3(self):
if condition:
self.error = "Found error3"
note: I don't want to throw an error but rather record it in class attr to be able later to extract it.