From badaeed1041109cab9b626ee431ea408e7f3d5bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=80=E1=B4=8D=E1=B4=9B=E1=B4=8F=E1=B4=80=E1=B4=87?= =?UTF-8?q?=CA=80?= Date: Mon, 22 Apr 2024 22:38:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E4=BD=86=E8=AF=BB=E5=8F=96=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E6=97=B6=E5=BA=94=E8=AF=A5=E4=BB=85=E6=8A=A5=E9=94=99=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E8=A6=86=E7=9B=96=E9=85=8D=E7=BD=AE=20(#71)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 614af53..d2421ba 100644 --- a/src/config.rs +++ b/src/config.rs @@ -11,7 +11,13 @@ use crate::bilibili::{Credential, DanmakuOption, FilterOption}; pub static CONFIG: Lazy = Lazy::new(|| { let config = Config::load().unwrap_or_else(|err| { - warn!("加载配置失败,错误为: {err},将使用默认配置..."); + if err + .downcast_ref::() + .map_or(true, |e| e.kind() != std::io::ErrorKind::NotFound) + { + panic!("加载配置文件失败,错误为: {err}"); + } + warn!("配置文件不存在,使用默认配置..."); Config::new() }); // 放到外面,确保新的配置项被保存