🔧 捕获所有异常以增强错误处理

- 将所有 `requests.exceptions.RequestException` 替换为 `Exception` 以捕获所有可能的异常
- 增强插件在遇到错误时的健壮性
This commit is contained in:
Cp0204 2024-12-03 21:32:46 +08:00
parent 16866a00b9
commit 53b4f94995
6 changed files with 11 additions and 11 deletions

View File

@ -51,7 +51,7 @@ try:
# 处理响应数据
# ......
# 返回
except requests.exceptions.RequestException as e:
except Exception as e:
print(f"Error: {e}")
return False
```

View File

@ -108,7 +108,7 @@ class Alist:
return data.get("data", [])
else:
print(f"Alist刷新: 存储{storage_id}连接失败❌ {data.get('message')}")
except requests.exceptions.RequestException as e:
except Exception as e:
print(f"Alist刷新: 获取Alist存储出错 {e}")
return []
@ -177,6 +177,6 @@ class Alist:
item["file_name"] for item in response["data"]["full_path"]
]
return "/".join(file_names)
except requests.exceptions.RequestException as e:
except Exception as e:
print(f"Alist刷新: 获取Quark路径出错 {e}")
return ""

View File

@ -51,7 +51,7 @@ class Alist_strm:
return True
else:
print(f"alist-strm配置运行: 匹配失败❌")
except requests.exceptions.RequestException as e:
except Exception as e:
print(f"获取alist-strm配置信息出错: {e}")
return False
@ -77,6 +77,6 @@ class Alist_strm:
return True
else:
print(f"🔗 alist-strm配置运行: 失败❌")
except requests.exceptions.RequestException as e:
except Exception as e:
print(f"Error: {e}")
return False

View File

@ -122,7 +122,7 @@ class Alist_strm_gen:
return data.get("data", [])
else:
print(f"Alist-Strm生成: 获取存储失败❌ {data.get('message')}")
except requests.exceptions.RequestException as e:
except Exception as e:
print(f"Alist-Strm生成: 获取存储出错 {e}")
return []
@ -202,6 +202,6 @@ class Alist_strm_gen:
item["file_name"] for item in response["data"]["full_path"]
]
return "/".join(file_names)
except requests.exceptions.RequestException as e:
except Exception as e:
print(f"Alist-Strm生成: 获取Quark路径出错 {e}")
return ""

View File

@ -74,7 +74,7 @@ class Aria2:
response = requests.post(self.rpc_url, json=jsonrpc_data)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
except Exception as e:
print(f"Aria2下载: 错误{e}")
return {}

View File

@ -53,7 +53,7 @@ class Emby:
return True
else:
print(f"Emby媒体库: 连接失败❌ {response.text}")
except requests.exceptions.RequestException as e:
except Exception as e:
print(f"获取Emby媒体库信息出错: {e}")
return False
@ -78,7 +78,7 @@ class Emby:
return True
else:
print(f"🎞️ 刷新Emby媒体库{response.text}")
except requests.exceptions.RequestException as e:
except Exception as e:
print(f"刷新Emby媒体库出错: {e}")
return False
@ -111,6 +111,6 @@ class Emby:
return item["Id"]
else:
print(f"🎞️ 搜索Emby媒体库{response.text}")
except requests.exceptions.RequestException as e:
except Exception as e:
print(f"搜索Emby媒体库出错: {e}")
return ""