From 22ba32c34f9b3d88049a6bbe3a0fa356f54da87a Mon Sep 17 00:00:00 2001 From: lhl Date: Thu, 13 Aug 2026 09:11:58 +0800 Subject: [PATCH] feat(writer): add WriterGenerationError --- src/genesis/writer/exceptions.py | 6 ++++++ tests/test_phase5_exceptions.py | 9 +++++++++ 2 files changed, 15 insertions(+) create mode 100644 src/genesis/writer/exceptions.py create mode 100644 tests/test_phase5_exceptions.py diff --git a/src/genesis/writer/exceptions.py b/src/genesis/writer/exceptions.py new file mode 100644 index 0000000..b096ff7 --- /dev/null +++ b/src/genesis/writer/exceptions.py @@ -0,0 +1,6 @@ +"""Writer 子系统异常。""" +from __future__ import annotations + + +class WriterGenerationError(Exception): + """LLM 章节生成失败(引擎 status 非 ok/fallback、或解析耗尽)。""" diff --git a/tests/test_phase5_exceptions.py b/tests/test_phase5_exceptions.py new file mode 100644 index 0000000..b5943f4 --- /dev/null +++ b/tests/test_phase5_exceptions.py @@ -0,0 +1,9 @@ +import pytest +from genesis.writer.exceptions import WriterGenerationError + + +def test_writer_generation_error_is_exception(): + with pytest.raises(WriterGenerationError): + raise WriterGenerationError("生成失败") + with pytest.raises(Exception): + raise WriterGenerationError("x")