Complete the code to define a custom exception class named MyError.
class MyError([1]): pass
Custom exceptions should inherit from Exception to be caught properly.
Complete the code to raise the custom exception MyError with a message.
raise MyError([1])When raising an exception, pass a string message describing the error.
Fix the error in the custom exception class to properly initialize the message.
class MyError(Exception): def __init__(self, message): [1]
Calling super().__init__(message) properly initializes the base Exception with the message.
Fill both blanks to create a custom exception with a code attribute and proper initialization.
class MyError(Exception): def __init__(self, message, code): [1] [2] = code
Use super().__init__(message) to initialize the message and assign self.code to store the code.
Fill all three blanks to catch the custom exception and print its message and code.
try: raise MyError("Failed", 404) except [1] as e: print(e[2]) print(e[3])
Catch the MyError exception, print the first argument (message) from args, and print the code attribute.