error handling take 2 (this time java-wrapper style)