Extract commonality about error handling into functions, encapsulated in a Handlers namespace.