text: # ------------------------------------
  # Copyright (c) Microsoft Corporation.
  # Licensed under the MIT License.
  # ------------------------------------
  import functools
  
  from six import raise_from
  
  from azure.core.exceptions import ClientAuthenticationError
  
  
  def wrap_exceptions(fn):
      """Prevents leaking exceptions defined outside azure-core by raising ClientAuthenticationError from them."""
  
      @functools.wraps(fn)
      def wrapper(*args, **kwargs):
          try:
              return fn(*args, **kwargs)
          except ClientAuthenticationError:
              raise
          except Exception as ex:
              auth_error = ClientAuthenticationError(message="Authentication failed: {}".format(ex))
              raise_from(auth_error, ex)
  
      return wrapper
  