add proper error reporting to open statements