🐛 修复 Sentry 发送多余错误 (#58)

This commit is contained in:
Xtao_dada 2021-04-04 12:31:32 +08:00 committed by GitHub
parent 1a0fa82ecb
commit 9efa803240
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -3,6 +3,7 @@
import sentry_sdk
from sentry_sdk.integrations.redis import RedisIntegration
from concurrent.futures import CancelledError
from subprocess import run, PIPE
from time import time
from os import getcwd, makedirs
@ -126,7 +127,9 @@ with bot:
def before_send(event, hint):
global report_time
exc_info = hint.get("exc_info")
if exc_info and isinstance(exc_info[0], CancelledError):
if exc_info and isinstance(exc_info[0], ConnectionError):
return None
elif exc_info and isinstance(exc_info[0], CancelledError):
return None
if time() <= report_time + 30:
report_time = time()

View File

@ -7,7 +7,6 @@ from random import choice
from json import load as load_json
from re import sub, IGNORECASE
from asyncio import create_subprocess_shell
from asyncio.exceptions import CancelledError
from asyncio.subprocess import PIPE
from youtube_dl import YoutubeDL
from pagermaid import module_dir, bot
@ -41,9 +40,8 @@ async def execute(command, pass_error=True):
try:
stdout, stderr = await executor.communicate()
except CancelledError:
result = "该操作已被取消。"
return result
except:
return "请求错误。"
if pass_error:
result = str(stdout.decode().strip()) \
+ str(stderr.decode().strip())