Added missing error handling.

Fixes #43.