mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Format pywintypes.error
This commit is contained in:
parent
9572aabb67
commit
c7cf5f6f70
1 changed files with 8 additions and 3 deletions
|
@ -1133,9 +1133,14 @@ def get_name(principal):
|
|||
|
||||
try:
|
||||
return win32security.LookupAccountSid(None, sid_obj)[0]
|
||||
except (pywintypes.error, TypeError):
|
||||
raise CommandExecutionError(
|
||||
'Could not find User for {0}'.format(principal))
|
||||
except (pywintypes.error, TypeError) as exc:
|
||||
if type(exc) == pywintypes.error:
|
||||
win_error = win32api.FormatMessage(exc.winerror).rstrip('\n')
|
||||
message = 'Error resolving {0} ({1})'.format(principal, win_error)
|
||||
else:
|
||||
message = 'Error resolving {0}'.format(principal)
|
||||
|
||||
raise CommandExecutionError(message)
|
||||
|
||||
|
||||
def get_owner(obj_name):
|
||||
|
|
Loading…
Add table
Reference in a new issue