Improved error detection for sqlite