Fix trailing white-space.
Fix indentation.
Catch the proper exception.
Merge pull request #6713 from s0undt3ch/develop

Code fixes