TransactionStateException
Exception thrown when the statement itself is fine and the transaction it arrived in is not.
The server rejects these before the statement is considered on its own merits, which is why they are not StatementException: nothing about the SQL is wrong, and the server sends no error position to point at. What is wrong is the state around it - a transaction an earlier error already doomed, one declared read-only, one open where the command forbids it, or none open where the command requires one.
25P02 is the one worth naming twice, because it is a consequence rather than a cause: after any error inside an explicit transaction PostgreSQL discards the work and rejects every further command until a ROLLBACK arrives. The failure to read is the first one; this one only says the session never left it.
The two class-25 timeouts, 25P03 and 25P04, are not here - a transaction the server aborted on a timer is ExecutionAbortedException with TRANSACTION_TIMEOUT, alongside the statement timeout it belongs with.
Parameters
The SQL state code returned by the database.
The original error message from the database server.