__str__.
class InputError(Exception):
def __init__(self, field):
super().__init__("bad " + field)
self.field = field
def __str__(self):
return self.field.upper()
try:
raise InputError("age")
except Exception as e:
print(e, e.args[0], isinstance(e, InputError))
What does the program print?Log in to join the discussion.
Loading…