This feels like a lot of redundant code with a try-catch in every throwable method. Have you considered making a class or helper function that takes in and calls a lambda wrapped in the try-catch? Something like:
def try_container_action(self, func):
try:
with ContainerRunning(self.container):
func()
except RuntimeError as e:
return handle_runtime_error(e)
Where "func" is a lambda for the one-liner in each method. You could also pull the contents of handle_runtime_error(e) into that method. Your thoughts?
This feels like a lot of redundant code with a try-catch in every throwable method. Have you considered making a class or helper function that takes in and calls a lambda wrapped in the try-catch? Something like:
def try_container_ action( self, func): g(self. container) : runtime_ error(e)
try:
with ContainerRunnin
func()
except RuntimeError as e:
return handle_
Where "func" is a lambda for the one-liner in each method. You could also pull the contents of handle_ runtime_ error(e) into that method. Your thoughts?