Look at error codes on exceptions, not the message.

closes #28

I really wish there was a better way to get at the error code, but
this is what I could find. Seems to work, at least.