From 9bf118225d51c25371c3e9f572f1de7ae4c5ddf7 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 4 Jan 2021 10:14:56 +0200 Subject: [PATCH] Exceptions: fix error when transforming django validation errors. --- etebase_fastapi/exceptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etebase_fastapi/exceptions.py b/etebase_fastapi/exceptions.py index d85c07e..d38ef42 100644 --- a/etebase_fastapi/exceptions.py +++ b/etebase_fastapi/exceptions.py @@ -115,5 +115,5 @@ def transform_validation_error(prefix: str, err: DjangoValidationError): elif not hasattr(err, "message"): errors = flatten_errors(prefix, err.error_list) else: - raise HttpError(err.code, err.message) + raise HttpError(err.code or "validation_error", err.message) raise HttpError(code="field_errors", detail="Field validations failed.", errors=errors)