Better error handling using exceptions by name

This commit is contained in:
Dionisio E Alonso 2015-04-09 16:26:48 -03:00
parent 271fffee79
commit 8b3c471361
1 changed files with 5 additions and 5 deletions

View File

@ -57,7 +57,7 @@ class SystemInformation:
'{}\\0000'.format(reg_key),
'HardwareInformation.AdapterString')
reg_keys.add(reg_key)
except:
except FileNotFoundError:
pass
video_cards = []
@ -68,14 +68,14 @@ class SystemInformation:
'SYSTEM\\CurrentControlSet\\Control\\Video\\'
'{}\\0000'.format(video_card),
'Device Description')
except:
except FileNotFoundError:
try:
device_descrption = get_registry_value(
'HKEY_LOCAL_MACHINE',
'SYSTEM\\CurrentControlSet\\Control\\Video\\'
'{}\\0000'.format(video_card),
'DriverDesc')
except:
except FileNotFoundError:
device_descrption = 'Failed to obtain video adapter.'
video_cards.append(device_descrption)
return '\n\t'.join(video_cards)
@ -123,10 +123,10 @@ class SystemInformation:
os = get('ProductName')
try:
sp = get('CSDVersion')
except:
except FileNotFoundError:
try:
sp = 'n' + get('CSDBuildNumber')
except:
except FileNotFoundError:
sp = '(no service pack found)'
build = get('CurrentBuildNumber')
return '{} {} (build {})'.format(os, sp, build)