๐
Create custom exception
How to create a new exception in Python
python
class InvalidOperationError(Exception): # new exceptionpassclass FileStream:def __init__(self):self.fileopen = Falsedef open(self):if self.fileopen:raise InvalidOperationError("The File is already open")self.fileopen = True
