checkClosed
Raises unless this connection is still usable, checking both what was asked of it and what happened to it — a connection closed by the caller and one whose stream broke underneath are different failures and are reported as different SQLSTATEs.
Finding a broken stream also latches the closed flag, so the second call answers from the flag rather than by asking a socket that is already gone.
Throws
CONNECTION_CLOSED (08003) if it was closed, CONNECTION_ERROR (08006) if the stream broke - with the server's own reason in details where it was the server that ended the session.