Refactor error containment into its own class for resue