Some error handling

My ruby is bad, so I'm cowardly not committing straight to master.