Skip to content

Commit ee452ea

Browse files
authored
Merge pull request #113 from jiasli/patch-1
Refine error messages of `PersistenceEncryptionError` and `PersistenceDecryptionError`
2 parents e30080b + 2aed3bc commit ee452ea

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

msal_extensions/persistence.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def save(self, content):
210210
except OSError as exception:
211211
raise PersistenceEncryptionError(
212212
err_no=getattr(exception, "winerror", None), # Exists in Python 3 on Windows
213-
message="Encryption failed: {}. Consider disable encryption.".format(exception),
213+
message="Encryption failed: {} Consider disable encryption.".format(exception),
214214
)
215215
with os.fdopen(_open(self._location), 'wb+') as handle:
216216
handle.write(data)
@@ -237,7 +237,7 @@ def load(self):
237237
except OSError as exception:
238238
raise PersistenceDecryptionError(
239239
err_no=getattr(exception, "winerror", None), # Exists in Python 3 on Windows
240-
message="Decryption failed: {}. "
240+
message="Decryption failed: {} "
241241
"App developer may consider this guidance: "
242242
"https://github.com/AzureAD/microsoft-authentication-extensions-for-python/wiki/PersistenceDecryptionError" # pylint: disable=line-too-long
243243
.format(exception),
@@ -342,4 +342,3 @@ def get_location(self):
342342
# with a FilePersistence to achieve
343343
# https://github.com/AzureAD/microsoft-authentication-extensions-for-python/issues/12
344344
# But this idea is not pursued at this time.
345-

msal_extensions/windows.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def raw(self):
4646
"The computer must be trusted for delegation and "
4747
"the current user account must be configured to allow delegation. "
4848
"See also https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/enable-computer-and-user-accounts-to-be-trusted-for-delegation",
49-
13: "The data is invalid",
49+
13: "The data is invalid.",
5050
}
5151

5252
# This code is modeled from a StackOverflow question, which can be found here:
@@ -91,7 +91,7 @@ def protect(self, message):
9191
_LOCAL_FREE(result.pbData)
9292

9393
err_code = _GET_LAST_ERROR()
94-
raise OSError(None, _err_description.get(err_code), None, err_code)
94+
raise OSError(None, _err_description.get(err_code, ''), None, err_code)
9595

9696
def unprotect(self, cipher_text):
9797
# type: (bytes) -> str
@@ -120,4 +120,4 @@ def unprotect(self, cipher_text):
120120
finally:
121121
_LOCAL_FREE(result.pbData)
122122
err_code = _GET_LAST_ERROR()
123-
raise OSError(None, _err_description.get(err_code), None, err_code)
123+
raise OSError(None, _err_description.get(err_code, ''), None, err_code)

0 commit comments

Comments
 (0)