mirror of
https://github.com/nexus-stc/hyperboria
synced 2025-01-28 19:37:34 +01:00
43be16e4bc
- [nexus] Remove outdated protos - [nexus] Development - [nexus] Development - [nexus] Development - [nexus] Development - [nexus] Development - [nexus] Refactor views - [nexus] Update aiosumma - [nexus] Add tags - [nexus] Development - [nexus] Update repository - [nexus] Update repository - [nexus] Update dependencies - [nexus] Update dependencies - [nexus] Fixes for MetaAPI - [nexus] Support for new queries - [nexus] Adopt new versions of search - [nexus] Improving Nexus - [nexus] Various fixes - [nexus] Add profile - [nexus] Fixes for ingestion - [nexus] Refactorings and bugfixes - [idm] Add profile methods - [nexus] Fix stalled nexus-meta bugs - [nexus] Various bugfixes - [nexus] Restore IDM API functionality GitOrigin-RevId: a0842345a6dde5b321279ab5510a50c0def0e71a
47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
import logging
|
|
import traceback
|
|
from contextlib import asynccontextmanager
|
|
from typing import (
|
|
Awaitable,
|
|
Callable,
|
|
Optional,
|
|
)
|
|
|
|
from library.logging import error_log
|
|
from telethon import (
|
|
errors,
|
|
events,
|
|
)
|
|
|
|
|
|
@asynccontextmanager
|
|
async def safe_execution(
|
|
error_log=error_log,
|
|
on_fail: Optional[Callable[[], Awaitable]] = None,
|
|
level=logging.WARNING,
|
|
):
|
|
try:
|
|
try:
|
|
yield
|
|
except events.StopPropagation:
|
|
raise
|
|
except errors.MessageNotModifiedError:
|
|
pass
|
|
except (
|
|
errors.UserIsBlockedError,
|
|
errors.QueryIdInvalidError,
|
|
errors.MessageDeleteForbiddenError,
|
|
errors.MessageIdInvalidError,
|
|
errors.ChatAdminRequiredError,
|
|
) as e:
|
|
error_log(e, level=level)
|
|
except Exception as e:
|
|
error_log(e, level=level)
|
|
traceback.print_exc()
|
|
if on_fail:
|
|
await on_fail()
|
|
except events.StopPropagation:
|
|
raise
|
|
except Exception as e:
|
|
error_log(e, level=level)
|