🐛 修复 Sentry 发送多余错误 (#58)
This commit is contained in:
parent
1a0fa82ecb
commit
9efa803240
@ -3,6 +3,7 @@
|
|||||||
import sentry_sdk
|
import sentry_sdk
|
||||||
|
|
||||||
from sentry_sdk.integrations.redis import RedisIntegration
|
from sentry_sdk.integrations.redis import RedisIntegration
|
||||||
|
from concurrent.futures import CancelledError
|
||||||
from subprocess import run, PIPE
|
from subprocess import run, PIPE
|
||||||
from time import time
|
from time import time
|
||||||
from os import getcwd, makedirs
|
from os import getcwd, makedirs
|
||||||
@ -126,7 +127,9 @@ with bot:
|
|||||||
def before_send(event, hint):
|
def before_send(event, hint):
|
||||||
global report_time
|
global report_time
|
||||||
exc_info = hint.get("exc_info")
|
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
|
return None
|
||||||
if time() <= report_time + 30:
|
if time() <= report_time + 30:
|
||||||
report_time = time()
|
report_time = time()
|
||||||
|
@ -7,7 +7,6 @@ from random import choice
|
|||||||
from json import load as load_json
|
from json import load as load_json
|
||||||
from re import sub, IGNORECASE
|
from re import sub, IGNORECASE
|
||||||
from asyncio import create_subprocess_shell
|
from asyncio import create_subprocess_shell
|
||||||
from asyncio.exceptions import CancelledError
|
|
||||||
from asyncio.subprocess import PIPE
|
from asyncio.subprocess import PIPE
|
||||||
from youtube_dl import YoutubeDL
|
from youtube_dl import YoutubeDL
|
||||||
from pagermaid import module_dir, bot
|
from pagermaid import module_dir, bot
|
||||||
@ -41,9 +40,8 @@ async def execute(command, pass_error=True):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
stdout, stderr = await executor.communicate()
|
stdout, stderr = await executor.communicate()
|
||||||
except CancelledError:
|
except:
|
||||||
result = "该操作已被取消。"
|
return "请求错误。"
|
||||||
return result
|
|
||||||
if pass_error:
|
if pass_error:
|
||||||
result = str(stdout.decode().strip()) \
|
result = str(stdout.decode().strip()) \
|
||||||
+ str(stderr.decode().strip())
|
+ str(stderr.decode().strip())
|
||||||
|
Loading…
Reference in New Issue
Block a user