From 16b12cf4708a5ac8941cc948c50dcddf74954502 Mon Sep 17 00:00:00 2001 From: "Gavin M. Roy" Date: Mon, 11 Jan 2021 22:31:54 -0500 Subject: [PATCH] Explicitly raise a FK error --- VERSION | 2 +- sprockets_postgres.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 9c6d629..bd8bf88 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.6.1 +1.7.0 diff --git a/sprockets_postgres.py b/sprockets_postgres.py index cd8995b..783ba73 100644 --- a/sprockets_postgres.py +++ b/sprockets_postgres.py @@ -760,6 +760,11 @@ class RequestHandlerMixin: raise problemdetails.Problem( status_code=500, title='Query Timeout') raise web.HTTPError(500, reason='Query Timeout') + elif isinstance(exc, errors.ForeignKeyViolation): + if problemdetails: + raise problemdetails.Problem( + status_code=409, title='Foreign Key Violation') + raise web.HTTPError(409, reason='Foreign Key Violation') elif isinstance(exc, errors.UniqueViolation): if problemdetails: raise problemdetails.Problem(