Skip to content

Commit 95ab890

Browse files
committed
Fix ctx in validation exception handler
1 parent bf16f89 commit 95ab890

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

backend/common/exception/exception_handler.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ async def _validation_exception_handler(exc: RequestValidationError | Validation
4646
if i18n.current_language != 'en-US':
4747
custom_message = t(f'pydantic.{error["type"]}')
4848
if custom_message:
49-
ctx = error.get('ctx')
50-
if not ctx:
49+
error_ctx = error.get('ctx')
50+
if not error_ctx:
5151
error['msg'] = custom_message
5252
else:
53-
ctx_error = ctx.get('error')
54-
if ctx_error:
55-
error['msg'] = custom_message.format(**ctx)
53+
e = error_ctx.get('error')
54+
if e:
55+
error['msg'] = custom_message.format(**error_ctx)
5656
error['ctx']['error'] = (
57-
ctx_error.__str__().replace("'", '"') if isinstance(ctx_error, Exception) else None
57+
e.__str__().replace("'", '"') if isinstance(e, Exception) else None
5858
)
5959
errors.append(error)
6060
error = errors[0]

0 commit comments

Comments
 (0)