Add some error handling

I don't know anything about OpenGL, so I have no idea if this is the correct way to do it, but some functions were failing on me so I figured this would be good to have.