From 6bd1cadf367dbdd00c1f50aad362311ea40790bf Mon Sep 17 00:00:00 2001 From: Sina Atalay <79940989+sinaatalay@users.noreply.github.com> Date: Tue, 9 Dec 2025 23:20:06 +0300 Subject: [PATCH] Improve error handling --- src/rendercv/schema/pydantic_error_handling.py | 12 ++++++++---- tests/renderer/templater/test_connections.py | 5 +++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/rendercv/schema/pydantic_error_handling.py b/src/rendercv/schema/pydantic_error_handling.py index 76691a56..885f49d6 100644 --- a/src/rendercv/schema/pydantic_error_handling.py +++ b/src/rendercv/schema/pydantic_error_handling.py @@ -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) diff --git a/tests/renderer/templater/test_connections.py b/tests/renderer/templater/test_connections.py index e701ae58..baf8ab4e 100644 --- a/tests/renderer/templater/test_connections.py +++ b/tests/renderer/templater/test_connections.py @@ -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"],