How to handle the error within the function that inside a loop without interrupting loop in Python?

There is a class:
class ExampleClass:
 def method_1(self, p1):
 # Do something 1

 def method_2(self, p1):
 # Do something 2

 def method_3(self, p1):
 # Do something 3

 def procerror(self, message):
method_1(message)
method_2(message)
method_3(message)

 def listen_kafka(self, p1):
 kafka = Kafka()
kafka.listen(procerror)


class Kafka:
 def listen(self, func_to_execute):
 # Listen kafka
 # ... some code for connet to kafka
 for message in 
 func_to_execute(message.value)


This is a very simplified code
For each message in Kafka, I consistently call methods of the class ExampleClass. Suppose in a method method_2 the error occurred, I treated, recorded logs how to make so that the program is not stopped but the following methods have not worked?
You just ignore the message and go to next message from Kafka
March 23rd 20 at 19:28
1 answer
March 23rd 20 at 19:30
Solution
Try it in a try except loop to use when error in except treat it

Find more questions by tags Python