mirror of
https://github.com/rendercv/rendercv.git
synced 2025-12-23 21:47:55 -05:00
Improve error handling
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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"],
|
||||
|
||||
Reference in New Issue
Block a user