Check for connection errors and throw