From 884dbff4b80dd5720241a16a3c01e0d483e6e131 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Tue, 25 Oct 2022 17:57:25 +0200 Subject: [PATCH] Log details of API exceptions --- src/pretix/api/exception.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pretix/api/exception.py b/src/pretix/api/exception.py index eaf5f4873..6f5e1c7fc 100644 --- a/src/pretix/api/exception.py +++ b/src/pretix/api/exception.py @@ -19,12 +19,19 @@ # You should have received a copy of the GNU Affero General Public License along with this program. If not, see # . # +import logging + +import ujson +from rest_framework import exceptions from rest_framework.response import Response from rest_framework.views import exception_handler, status from pretix.base.services.locking import LockTimeoutException +logger = logging.getLogger(__name__) + + def custom_exception_handler(exc, context): response = exception_handler(exc, context) @@ -37,4 +44,7 @@ def custom_exception_handler(exc, context): } ) + if isinstance(exc, exceptions.APIException): + logger.info(f'API Exception [{exc.status_code}]: {ujson.dumps(exc.detail)}') + return response