def api_wrapper(func):
 @wraps(func)
 def __wrapper(*args, **kwargs):
  module = args[0]
  try:
   return func(*args, **kwargs)
  except core.exceptions.APICommandException as e:
   module.fail_json(msg=e.message)
  except core.exceptions.SystemNotFoundException as e:
   module.fail_json(msg=e.message)
  except:
   raise
 return __wrapper

def api_wrapper ( func ) : @ wraps ( func ) def __wrapper ( * args , ** kwargs ) : module = args [ 0 ] try : return func ( * args , ** kwargs ) except core . exceptions . APICommandException as e : module . fail_json ( msg = e . message ) except core . exceptions . SystemNotFoundException as e : module . fail_json ( msg = e . message ) except : raise return __wrapper
catch api errors decorator .