From c0904ea4642f2f4948fbdaf5af33b30bd2987b08 Mon Sep 17 00:00:00 2001 From: ZhangJinxuan <2194936226@qq.com> Date: Mon, 25 May 2026 15:05:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E8=BF=9C=E7=A8=8B=E5=B9=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0excption?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- excption/Repoditory.java | 19 +++++++++++++++++++ excption/excption.java | 7 +++++++ excption/新建 文本文档.txt | 0 3 files changed, 26 insertions(+) create mode 100644 excption/Repoditory.java create mode 100644 excption/excption.java create mode 100644 excption/新建 文本文档.txt 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