Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
Catch decryption error and provide user with message. Closes #132.
Browse files Browse the repository at this point in the history
  • Loading branch information
chambridge committed Aug 16, 2017
1 parent e7cf6d9 commit 52f2425
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rho/vault.py
Expand Up @@ -12,13 +12,16 @@

from __future__ import print_function
import os
import sys
import json
import uuid
from tempfile import gettempdir
from shutil import move
from getpass import getpass
import yaml
from ansible.parsing.vault import VaultLib
from ansible.errors import AnsibleError
from rho.translation import _ as t


def represent_none(self, _):
Expand Down Expand Up @@ -88,7 +91,11 @@ def load(self, stream):
:param stream: The stream to read data from
:returns: The decrypted data
"""
return self.vault.decrypt(stream)
try:
return self.vault.decrypt(stream)
except AnsibleError:
print(t("Unable to decrypt file using given vault password"))
sys.exit(1)

def load_secure_file(self, secure_file):
""" Read vault secured file and return python object
Expand Down

0 comments on commit 52f2425

Please sign in to comment.