Detect query timeouts and throw a specific exception