3 changed files with 26 additions and 0 deletions
@ -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; |
|||
} |
|||
// 原有保存逻辑
|
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
package exception; |
|||
|
|||
public class ParseException extends CrawlerException { |
|||
public ParseException(String message) { |
|||
super(message); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue