Skip to content

Commit

Permalink
add try/except block
Browse files Browse the repository at this point in the history
  • Loading branch information
abikouo committed Feb 11, 2022
1 parent afc53ec commit 7e0faf3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion plugins/modules/k8s_cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
K8SCopyToPod,
check_pod,
)
from ansible.module_utils._text import to_native


def argspec():
Expand Down Expand Up @@ -197,7 +198,11 @@ def execute_module(module):
k8s_copy = K8SCopyToPod(module, k8s_ansible_mixin.client)
else:
k8s_copy = K8SCopyFromPod(module, k8s_ansible_mixin.client)
k8s_copy.run()

try:
k8s_copy.run()
except Exception as e:
module.fail_json("Failed to copy object due to: {0}".format(to_native(e)))


def main():
Expand Down

0 comments on commit 7e0faf3

Please sign in to comment.