Code review comment for lp:~townsend/libertine/catch-runtime-errors

Revision history for this message
Larry Price (larryprice) wrote :

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?

« Back to merge proposal