Extract error handling to Rescue.

Closes #373.