Your code seems a little paranoid. It's constantly checking for error states. I think it makes it harder to follow the normal course of your program.

I think readability would be improved if you took a more "let it crash if something weird is going on" approach.