Improve error handling

This commit is contained in:
Sina Atalay
2025-12-09 23:20:06 +03:00
parent 9e5130ee2d
commit 6bd1cadf36
2 changed files with 11 additions and 6 deletions

View File

@@ -70,13 +70,17 @@ def parse_plain_pydantic_error(
' or YYYY format or "present"!'
)
error_message = error_dictionary.get(plain_error["msg"], plain_error["msg"])
if not error_message.endswith("."):
error_message += "."
for old_error_message, new_error_message in error_dictionary.items():
if old_error_message in plain_error["msg"]:
plain_error["msg"] = new_error_message
break
if not plain_error["msg"].endswith("."):
plain_error["msg"] += "."
return RenderCVValidationError(
location=location,
message=error_message,
message=plain_error["msg"],
input=(
str(plain_error["input"])
if not isinstance(plain_error["input"], dict | list)

View File

@@ -1,5 +1,6 @@
from typing import Literal, get_args
import pydantic
import pytest
from rendercv.renderer.templater.connections import (
@@ -238,7 +239,7 @@ class TestParseConnections:
custom_connection = CustomConnection(
fontawesome_icon="calendar-days",
placeholder="Book a call",
url="https://cal.com/johndoe",
url=pydantic.HttpUrl("https://cal.com/johndoe"),
)
cv = create_cv(
key_order=["custom_connections"],
@@ -357,7 +358,7 @@ class TestComputeConnectionsForMarkdown:
custom_connection = CustomConnection(
fontawesome_icon="calendar-days",
placeholder="Book a call",
url="https://cal.com/johndoe",
url=pydantic.HttpUrl("https://cal.com/johndoe"),
)
cv = create_cv(
key_order=["custom_connections"],