proper error handling, fixed #485
Merge pull request #491 from ethereum/error_handling_fix

proper error handling in javascript api, fixed #485