fixes frappe#119, frappe#121
Merge pull request frappe#59 from resilient-tech/fix-error-handling fix: error handling