Create safer format_exception staticmethod