mirror of
https://github.com/sprockets/sprockets-postgres.git
synced 2025-04-13 01:11:02 -09:00
added psycopg2.Error back
This commit is contained in:
parent
725fba8728
commit
2eb4dd0f9e
2 changed files with 5 additions and 0 deletions
|
@ -350,6 +350,8 @@ class ApplicationMixin:
|
|||
_attempt + 1) as connector:
|
||||
yield connector
|
||||
return
|
||||
# Handle timeout error during cursor creation as
|
||||
# operational error
|
||||
elif isinstance(err, asyncio.TimeoutError):
|
||||
exc = on_error(
|
||||
'postgres_connector', psycopg2.OperationalError(err))
|
||||
|
@ -684,6 +686,8 @@ class RequestHandlerMixin:
|
|||
raise web.HTTPError(500, reason='Query Timeout')
|
||||
elif isinstance(exc, errors.UniqueViolation):
|
||||
raise web.HTTPError(409, reason='Unique Violation')
|
||||
elif isinstance(exc, psycopg2.Error):
|
||||
raise web.HTTPError(500, reason='Database Error')
|
||||
return exc
|
||||
|
||||
def _on_postgres_timing(self,
|
||||
|
|
1
tests.py
1
tests.py
|
@ -390,6 +390,7 @@ class RequestHandlerMixinTestCase(TestCase):
|
|||
execute.side_effect = psycopg2.Error()
|
||||
response = self.fetch('/execute?value=1')
|
||||
self.assertEqual(response.code, 500)
|
||||
self.assertIn(b'Database Error', response.body)
|
||||
|
||||
@mock.patch('aiopg.cursor.Cursor.fetchone')
|
||||
def test_postgres_programming_error(self, fetchone):
|
||||
|
|
Loading…
Add table
Reference in a new issue