Wrapped entire code block in try to catch exceptions
Added a few different exceptions that are likely to happen when trying to use this tool. It then offers useful feedback and quits.
This commit is contained in:
parent
48df386b7e
commit
487f6ffb46
1 changed files with 72 additions and 62 deletions
|
@ -23,6 +23,7 @@ static unsigned char {0}_bits [] =
|
|||
|
||||
outputData = b''
|
||||
|
||||
try:
|
||||
with open(filename + ".MSP", 'rb') as f:
|
||||
versionString = f.read(4)
|
||||
if versionString == b'\x4c\x69\x6e\x53':
|
||||
|
@ -92,3 +93,12 @@ with open(filename + ".MSP", 'rb') as f:
|
|||
f.write(outputString)
|
||||
print("Done!")
|
||||
sys.exit(0)
|
||||
except FileNotFoundError:
|
||||
print("{0}.MSP does not exist! Quitting...".format(filename))
|
||||
sys.exit(255)
|
||||
except PermissionError:
|
||||
print("Unable to open {0}.MSP -- insufficient permissions! Quitting...".format(filename))
|
||||
sys.exit(255)
|
||||
except Exception:
|
||||
print("Something went wrong! Quitting...")
|
||||
sys.exit(255)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue