updated error handling
Merge branch 'master' into tojs
Merge pull request #64 from Postmedia/tojs

updated error handling