mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
Use common functions for handling import errors (#51851)
* Use common functions for handling import errors * use refactored version of gitlab modules
This commit is contained in:
parent
28dcfa985f
commit
c1e51ef486
39 changed files with 233 additions and 93 deletions
|
@ -161,15 +161,19 @@ RETURN = r'''
|
|||
#
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
IMPORT_IMP_ERR = None
|
||||
try:
|
||||
from importlib import import_module
|
||||
HAS_IMPORT_MODULE = True
|
||||
except Exception:
|
||||
IMPORT_IMP_ERR = traceback.format_exc()
|
||||
HAS_IMPORT_MODULE = False
|
||||
|
||||
from copy import deepcopy
|
||||
import json
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils.remote_management.ucs import UCSModule, ucs_argument_spec
|
||||
|
||||
|
||||
|
@ -241,7 +245,7 @@ def main():
|
|||
)
|
||||
|
||||
if not HAS_IMPORT_MODULE:
|
||||
module.fail_json(msg='import_module is required for this module')
|
||||
module.fail_json(msg=missing_required_lib('importlib'), exception=IMPORT_IMP_ERR)
|
||||
ucs = UCSModule(module)
|
||||
|
||||
ucs.result['err'] = False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue