added general error handling
Merge pull request #166 from tzumainn/master

added general error handling