set error handler and throw exceptions on error case