mirror of
https://github.com/pretix/pretix.git
synced 2026-05-09 15:54:03 +00:00
Log details of API exceptions
This commit is contained in:
@@ -19,12 +19,19 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
||||||
# <https://www.gnu.org/licenses/>.
|
# <https://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
import logging
|
||||||
|
|
||||||
|
import ujson
|
||||||
|
from rest_framework import exceptions
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.views import exception_handler, status
|
from rest_framework.views import exception_handler, status
|
||||||
|
|
||||||
from pretix.base.services.locking import LockTimeoutException
|
from pretix.base.services.locking import LockTimeoutException
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def custom_exception_handler(exc, context):
|
def custom_exception_handler(exc, context):
|
||||||
response = 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
|
return response
|
||||||
|
|||||||
Reference in New Issue
Block a user