Change 'except Exception' to 'except BaseException'
This commit is contained in:
parent
5a3a7eca51
commit
a2fe972793
|
@ -94,17 +94,17 @@ def log_errors(func):
|
||||||
await func(client, *args)
|
await func(client, *args)
|
||||||
except (StopPropagation, ContinuePropagation):
|
except (StopPropagation, ContinuePropagation):
|
||||||
raise
|
raise
|
||||||
except Exception:
|
except BaseException:
|
||||||
tb = traceback.format_exc()
|
tb = traceback.format_exc()
|
||||||
try:
|
try:
|
||||||
await slave.send_message(config['config']['log_chat'], f'Exception occured in {func.__name__}\n\n{tb}', parse_mode=None)
|
await slave.send_message(config['config']['log_chat'], f'Exception occured in {func.__name__}\n\n{tb}', parse_mode=None)
|
||||||
except Exception:
|
except BaseException:
|
||||||
logging.exception('Failed to log exception for %s as slave', func.__name__)
|
logging.exception('Failed to log exception for %s as slave', func.__name__)
|
||||||
tb = traceback.format_exc()
|
tb = traceback.format_exc()
|
||||||
for app in apps:
|
for app in apps:
|
||||||
try:
|
try:
|
||||||
await app.send_message(config['config']['log_chat'], f'Exception occured in {func.__name__}\n\n{tb}', parse_mode=None)
|
await app.send_message(config['config']['log_chat'], f'Exception occured in {func.__name__}\n\n{tb}', parse_mode=None)
|
||||||
except Exception:
|
except BaseException:
|
||||||
logging.exception('Failed to log exception for %s as app', func.__name__)
|
logging.exception('Failed to log exception for %s as app', func.__name__)
|
||||||
tb = traceback.format_exc()
|
tb = traceback.format_exc()
|
||||||
else:
|
else:
|
||||||
|
@ -120,7 +120,7 @@ def public_log_errors(func):
|
||||||
await func(client, message)
|
await func(client, message)
|
||||||
except (StopPropagation, ContinuePropagation):
|
except (StopPropagation, ContinuePropagation):
|
||||||
raise
|
raise
|
||||||
except Exception:
|
except BaseException:
|
||||||
await message.reply_text(traceback.format_exc(), parse_mode=None)
|
await message.reply_text(traceback.format_exc(), parse_mode=None)
|
||||||
raise
|
raise
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
|
@ -95,7 +95,7 @@ async def get_spamwatch(entity):
|
||||||
async with session.get(f'https://api.spamwat.ch/banlist/{entity}', headers={'Authorization': f'Bearer {config["config"]["spamwatch_api"]}'}) as resp:
|
async with session.get(f'https://api.spamwat.ch/banlist/{entity}', headers={'Authorization': f'Bearer {config["config"]["spamwatch_api"]}'}) as resp:
|
||||||
try:
|
try:
|
||||||
json = await resp.json()
|
json = await resp.json()
|
||||||
except Exception as ex:
|
except BaseException as ex:
|
||||||
return f'- <b>{resp.status}:</b> {html.escape(type(ex).__name__)}: {html.escape(str(ex))}'
|
return f'- <b>{resp.status}:</b> {html.escape(type(ex).__name__)}: {html.escape(str(ex))}'
|
||||||
if 'code' in json:
|
if 'code' in json:
|
||||||
return f'- <b>{json["code"]}:</b> {html.escape(json.get("error", ""))}'
|
return f'- <b>{json["code"]}:</b> {html.escape(json.get("error", ""))}'
|
||||||
|
@ -156,7 +156,7 @@ async def get_cas(entity):
|
||||||
async with session.get(f'https://api.cas.chat/check?user_id={entity}') as resp:
|
async with session.get(f'https://api.cas.chat/check?user_id={entity}') as resp:
|
||||||
try:
|
try:
|
||||||
json = await resp.json()
|
json = await resp.json()
|
||||||
except Exception as ex:
|
except BaseException as ex:
|
||||||
return f'- <b>{resp.status}:</b> {html.escape(type(ex).__name__)}: {html.escape(str(ex))}'
|
return f'- <b>{resp.status}:</b> {html.escape(type(ex).__name__)}: {html.escape(str(ex))}'
|
||||||
if json['ok']:
|
if json['ok']:
|
||||||
return f'''- <b>Banned on:</b> {str(datetime.datetime.fromisoformat(json["result"]["time_added"][:-1]))}
|
return f'''- <b>Banned on:</b> {str(datetime.datetime.fromisoformat(json["result"]["time_added"][:-1]))}
|
||||||
|
@ -167,7 +167,7 @@ async def get_spam_protection(entity):
|
||||||
async with session.get(f'https://api.intellivoid.net/spamprotection/v1/lookup?query={entity}') as resp:
|
async with session.get(f'https://api.intellivoid.net/spamprotection/v1/lookup?query={entity}') as resp:
|
||||||
try:
|
try:
|
||||||
json = await resp.json()
|
json = await resp.json()
|
||||||
except Exception as ex:
|
except BaseException as ex:
|
||||||
return f'- <b>{resp.status}:</b> {html.escape(type(ex).__name__)}: {html.escape(str(ex))}'
|
return f'- <b>{resp.status}:</b> {html.escape(type(ex).__name__)}: {html.escape(str(ex))}'
|
||||||
if json['success']:
|
if json['success']:
|
||||||
text = ''
|
text = ''
|
||||||
|
|
|
@ -19,7 +19,7 @@ async def ls(client, message):
|
||||||
(folders if os.path.isdir(os.path.join(dir, i)) else files).append(i)
|
(folders if os.path.isdir(os.path.join(dir, i)) else files).append(i)
|
||||||
except NotADirectoryError:
|
except NotADirectoryError:
|
||||||
text = f'<code>{html.escape(os.path.basename(dir))}</code>'
|
text = f'<code>{html.escape(os.path.basename(dir))}</code>'
|
||||||
except Exception as ex:
|
except BaseException as ex:
|
||||||
text = f'{type(ex).__name__}: {html.escape(str(ex))}'
|
text = f'{type(ex).__name__}: {html.escape(str(ex))}'
|
||||||
else:
|
else:
|
||||||
for i in folders:
|
for i in folders:
|
||||||
|
|
|
@ -40,7 +40,7 @@ async def info(client, message):
|
||||||
entity = message.reply_to_message.from_user or message.reply_to_message.chat
|
entity = message.reply_to_message.from_user or message.reply_to_message.chat
|
||||||
try:
|
try:
|
||||||
entity, entity_client = await get_entity(client, entity)
|
entity, entity_client = await get_entity(client, entity)
|
||||||
except Exception as ex:
|
except BaseException as ex:
|
||||||
await message.reply_text(f'{type(ex).__name__}: {str(ex)}', parse_mode=None)
|
await message.reply_text(f'{type(ex).__name__}: {str(ex)}', parse_mode=None)
|
||||||
return
|
return
|
||||||
text_ping = _generate_sexy(entity, True)
|
text_ping = _generate_sexy(entity, True)
|
||||||
|
|
|
@ -32,7 +32,7 @@ def _generate(i):
|
||||||
try:
|
try:
|
||||||
resp = requests.get('https://nekos.life/api/v2/endpoints')
|
resp = requests.get('https://nekos.life/api/v2/endpoints')
|
||||||
json = resp.json()
|
json = resp.json()
|
||||||
except Exception:
|
except BaseException:
|
||||||
logging.exception('Cannot connect to nekos.life')
|
logging.exception('Cannot connect to nekos.life')
|
||||||
else:
|
else:
|
||||||
for i in json:
|
for i in json:
|
||||||
|
|
|
@ -76,7 +76,7 @@ async def whatanime(client, message):
|
||||||
file.seek(0)
|
file.seek(0)
|
||||||
try:
|
try:
|
||||||
await reply.reply_video(file.name, caption=f'{from_time} - {to_time}')
|
await reply.reply_video(file.name, caption=f'{from_time} - {to_time}')
|
||||||
except Exception:
|
except BaseException:
|
||||||
await reply.reply_text('Cannot send preview :/')
|
await reply.reply_text('Cannot send preview :/')
|
||||||
await asyncio.gather(reply.edit_text(text, disable_web_page_preview=True), _send_preview())
|
await asyncio.gather(reply.edit_text(text, disable_web_page_preview=True), _send_preview())
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ def _generate(i):
|
||||||
try:
|
try:
|
||||||
resp = requests.get('https://nekos.life/api/v2/endpoints')
|
resp = requests.get('https://nekos.life/api/v2/endpoints')
|
||||||
json = resp.json()
|
json = resp.json()
|
||||||
except Exception:
|
except BaseException:
|
||||||
logging.exception('Cannot connect to nekos.life')
|
logging.exception('Cannot connect to nekos.life')
|
||||||
else:
|
else:
|
||||||
for i in json:
|
for i in json:
|
||||||
|
|
Loading…
Reference in New Issue