Skip to content

Commit 1f9b3fc

Browse files
committed
feat(exception): add PoetryRuntimeError.append()
1 parent c4f0fd5 commit 1f9b3fc

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/poetry/console/exceptions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,9 @@ def create(
222222
)
223223

224224
return cls(reason, messages)
225+
226+
def append(self, message: str | ConsoleMessage) -> PoetryRuntimeError:
227+
if isinstance(message, str):
228+
message = ConsoleMessage(message)
229+
self._messages.append(message)
230+
return self

tests/console/test_exections_poetry_runtime_error.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,10 @@ def test_poetry_runtime_error_create(
139139

140140
actual_texts = [msg.text for msg in error._messages]
141141
assert actual_texts == expected_message_texts
142+
143+
144+
def test_poetry_runtime_error_append() -> None:
145+
"""Test the append method of PoetryRuntimeError."""
146+
error = PoetryRuntimeError.create("Error", info=["Hello"]).append("World")
147+
actual_texts = [msg.text for msg in error._messages]
148+
assert actual_texts == ["Error", "<info>Hello</>", "World"]

0 commit comments

Comments
 (0)