Added some try-except blocks for various errors.