mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-08 07:18:47 +00:00
Handle config decryption errors gracefully
This commit is contained in:
@@ -409,11 +409,13 @@ class EncryptionManager:
|
||||
if return_kdf:
|
||||
return data, kdf
|
||||
return data
|
||||
except (InvalidToken, InvalidTag, JSONDecodeError) as e:
|
||||
logger.error(
|
||||
f"FATAL: Could not decrypt or parse data from {file_path}: {e}",
|
||||
exc_info=True,
|
||||
)
|
||||
except (InvalidToken, InvalidTag) as e:
|
||||
msg = f"Failed to decrypt or parse data from {file_path}: {e}"
|
||||
logger.error(msg)
|
||||
raise InvalidToken(msg) from e
|
||||
except JSONDecodeError as e:
|
||||
msg = f"Failed to parse JSON data from {file_path}: {e}"
|
||||
logger.error(msg)
|
||||
raise
|
||||
|
||||
def get_encrypted_index(self) -> Optional[bytes]:
|
||||
|
@@ -4420,6 +4420,15 @@ class PasswordManager:
|
||||
else:
|
||||
logging.warning("Password verification failed.")
|
||||
return is_correct
|
||||
except InvalidToken as e:
|
||||
logging.error(f"Failed to decrypt config: {e}")
|
||||
print(
|
||||
colored(
|
||||
"Error: Could not decrypt configuration. The password may be incorrect or the file may be corrupted.",
|
||||
"red",
|
||||
)
|
||||
)
|
||||
return False
|
||||
except Exception as e:
|
||||
logging.error(f"Error verifying password: {e}", exc_info=True)
|
||||
print(colored(f"Error: Failed to verify password: {e}", "red"))
|
||||
|
Reference in New Issue
Block a user