Added try and except statements to fix Issue #18

Also, added a log to catch the error and the message that caused the error.