parameters: (func)
return_statement: return wrapper
docstring: If the decorated function raises and exception the remove any workspaces
      from from the ADS that were added during the wrapped function call.
      The exception raised in the wrapper is reraised.
docstring_summary: If the decorated function raises and exception the remove any workspaces
      from from the ADS that were added during the wrapped function call.
      The exception raised in the wrapper is reraised.
docstring_tokens: If the decorated function raises and exception the remove any workspaces from from the ADS that were added during the wrapped function call . The exception raised in the wrapper is reraised .
function: def on_except_leave_ads_unchanged(func):
      """
      If the decorated function raises and exception the remove any workspaces
      from from the ADS that were added during the wrapped function call.
      The exception raised in the wrapper is reraised.
      """
  
      def wrapper(*args, **kwargs):
          ads = AnalysisDataService.Instance()
          names_before = set(ads.getObjectNames())
          try:
              return func(*args, **kwargs)
          except Exception as exc:
              added_names = set(ads.getObjectNames()) - names_before
              for name in added_names:
                  ads.remove(name)
              raise exc
  
      return wrapper
function_tokens: def on_except_leave_ads_unchanged ( func ) : def wrapper ( * args , * * kwargs ) : ads = AnalysisDataService . Instance ( ) names_before = set ( ads . getObjectNames ( ) ) try : return func ( * args , * * kwargs ) except Exception as exc : added_names = set ( ads . getObjectNames ( ) ) - names_before for name in added_names : ads . remove ( name ) raise exc return wrapper