diff --git a/excption/Repoditory.java b/excption/Repoditory.java new file mode 100644 index 0000000..d88ea2a --- /dev/null +++ b/excption/Repoditory.java @@ -0,0 +1,19 @@ +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ArticleRepository { + private static final Logger log = LoggerFactory.getLogger(ArticleRepository.class); + + public void save(Article article) { + // 防御检查:空值拦截 + if (article == null) { + log.warn("保存文章失败:article为空"); + return; + } + if (article.getTitle() == null || article.getTitle().isBlank()) { + log.warn("保存文章失败:标题为空"); + return; + } + // 原有保存逻辑 + } +} \ No newline at end of file diff --git a/excption/excption.java b/excption/excption.java new file mode 100644 index 0000000..506ba6f --- /dev/null +++ b/excption/excption.java @@ -0,0 +1,7 @@ +package exception; + +public class ParseException extends CrawlerException { + public ParseException(String message) { + super(message); + } +} \ No newline at end of file diff --git a/excption/新建 文本文档.txt b/excption/新建 文本文档.txt new file mode 100644 index 0000000..e69de29