Verify that a OpenGL context is available when checking errors

glGet seems to be a no-op if no OpenGL context is available, which
was causing a std::logic_error. This commit catches that contingency and
emits an error that Lua can catch.