if result.status == ExecStatus.FATAL_ERROR:
raise e.error_from_result(result, encoding=pgconn_encoding(self.pgconn))
elif result.status == ExecStatus.PIPELINE_ABORTED:
- raise e.OperationalError("pipeline aborted")
+ raise e.PipelineAborted("pipeline aborted")
else:
cursor, prepinfo = queued
cursor._set_results_from_pipeline(results)
if result.status == ExecStatus.FATAL_ERROR:
raise e.error_from_result(result, encoding=self._encoding)
elif result.status == ExecStatus.PIPELINE_ABORTED:
- raise e.OperationalError("pipeline aborted")
+ raise e.PipelineAborted("pipeline aborted")
elif result.status in self._status_copy:
raise e.ProgrammingError(
"COPY cannot be used with this method; use copy() insead"
elif res.status == ExecStatus.FATAL_ERROR:
raise e.error_from_result(res, encoding=pgconn_encoding(self._pgconn))
elif res.status == ExecStatus.PIPELINE_ABORTED:
- raise e.OperationalError("pipeline aborted")
+ raise e.PipelineAborted("pipeline aborted")
elif res.status != ExecStatus.TUPLES_OK:
raise e.ProgrammingError("the last operation didn't produce a result")
"""
+class PipelineAborted(OperationalError):
+ """
+ Raised when a operation fails because the current pipeline is in aborted state.
+
+ Subclass of `~psycopg.OperationalError`.
+ """
+
+
class Diagnostic:
"""Details from a database error report."""
c1 = conn.execute("select 1")
with pytest.raises(e.UndefinedTable):
conn.execute("select * from doesnotexist").fetchone()
- with pytest.raises(e.OperationalError, match="pipeline aborted"):
+ with pytest.raises(e.PipelineAborted):
conn.execute("select 'aborted'").fetchone()
# Sync restore the connection in usable state.
p.sync()
c1 = await aconn.execute("select 1")
with pytest.raises(e.UndefinedTable):
await (await aconn.execute("select * from doesnotexist")).fetchone()
- with pytest.raises(e.OperationalError, match="pipeline aborted"):
+ with pytest.raises(e.PipelineAborted):
await (await aconn.execute("select 'aborted'")).fetchone()
# Sync restore the connection in usable state.
await p.sync()