exp is now exc
This commit is contained in:
parent
5e8506cc12
commit
1d88076285
@ -104,8 +104,8 @@ class PyroClient(PyroClient):
|
||||
logger.warning(
|
||||
"Could not send startup message to bot owner. Perhaps user has not started the bot yet."
|
||||
)
|
||||
except Exception as exp:
|
||||
logger.exception("Update check failed due to %s: %s", exp, format_exc())
|
||||
except Exception as exc:
|
||||
logger.exception("Update check failed due to %s: %s", exc, format_exc())
|
||||
|
||||
if self.config["mode"]["post"]:
|
||||
if self.config["posting"]["use_interval"]:
|
||||
@ -155,8 +155,8 @@ class PyroClient(PyroClient):
|
||||
filepath = await self.download_media(
|
||||
submission, file_name=self.config["locations"]["tmp"] + sep
|
||||
)
|
||||
except Exception as exp:
|
||||
raise SubmissionUnavailableError() from exp
|
||||
except Exception as exc:
|
||||
raise SubmissionUnavailableError() from exc
|
||||
|
||||
elif not Path(
|
||||
f"{self.config['locations']['data']}/submissions/{db_entry['temp']['uuid']}/{db_entry['temp']['file']}",
|
||||
@ -204,8 +204,8 @@ class PyroClient(PyroClient):
|
||||
# ),
|
||||
# caption="queue",
|
||||
# )
|
||||
except UnexpectedStatus as exp:
|
||||
raise SubmissionUnsupportedError(str(filepath)) from exp
|
||||
except UnexpectedStatus as exc:
|
||||
raise SubmissionUnsupportedError(str(filepath)) from exc
|
||||
|
||||
response_dict = (
|
||||
{}
|
||||
|
@ -58,8 +58,8 @@ async def cli_create_user() -> None:
|
||||
none = input(
|
||||
"Alright. If you have email confirmation enabled - please confirm registration by using the link in your email. After that press Enter. Otherwise just press Enter."
|
||||
)
|
||||
except Exception as exp:
|
||||
print(f"Could not create a user due to {exp}", flush=True)
|
||||
except Exception as exc:
|
||||
print(f"Could not create a user due to {exc}", flush=True)
|
||||
print_exc()
|
||||
exit()
|
||||
if not args.create_album:
|
||||
@ -97,8 +97,8 @@ async def cli_create_album() -> None:
|
||||
result_2 = await album_create(client=client, name=name, title=title)
|
||||
# asyncio.run(create_album(name, title))
|
||||
await config_set("album", name, "posting", "api")
|
||||
except Exception as exp:
|
||||
print(f"Could not create an album due to {exp}", flush=True)
|
||||
except Exception as exc:
|
||||
print(f"Could not create an album due to {exc}", flush=True)
|
||||
print_exc()
|
||||
exit()
|
||||
print("You're done!", flush=True)
|
||||
|
@ -77,12 +77,12 @@ async def send_content(app: PyroClient, http_session: ClientSession) -> None:
|
||||
|
||||
try:
|
||||
response: File = await func_iter[1](id=media.id, client=client)
|
||||
except Exception as exp:
|
||||
except Exception as exc:
|
||||
print_exc()
|
||||
logger.error("Media is invalid: %s", exp)
|
||||
logger.error("Media is invalid: %s", exc)
|
||||
if app.config["reports"]["error"]:
|
||||
await app.send_message(
|
||||
app.owner, f"Media is invalid: {exp}"
|
||||
app.owner, f"Media is invalid: {exc}"
|
||||
)
|
||||
return
|
||||
|
||||
@ -103,11 +103,11 @@ async def send_content(app: PyroClient, http_session: ClientSession) -> None:
|
||||
).results[0]
|
||||
try:
|
||||
response: File = await func[1](id=media.id, client=client)
|
||||
except Exception as exp:
|
||||
except Exception as exc:
|
||||
print_exc()
|
||||
logger.error("Media is invalid: %s", exp)
|
||||
logger.error("Media is invalid: %s", exc)
|
||||
if app.config["reports"]["error"]:
|
||||
await app.send_message(app.owner, f"Media is invalid: {exp}")
|
||||
await app.send_message(app.owner, f"Media is invalid: {exc}")
|
||||
return
|
||||
|
||||
except (KeyError, AttributeError, TypeError, IndexError):
|
||||
@ -217,14 +217,14 @@ async def send_content(app: PyroClient, http_session: ClientSession) -> None:
|
||||
caption=caption,
|
||||
disable_notification=app.config["posting"]["silent"],
|
||||
)
|
||||
except Exception as exp:
|
||||
except Exception as exc:
|
||||
logger.error(
|
||||
"Could not send media %s (%s) due to %s", media.filename, media.id, exp
|
||||
"Could not send media %s (%s) due to %s", media.filename, media.id, exc
|
||||
)
|
||||
if app.config["reports"]["error"]:
|
||||
await app.send_message(
|
||||
app.owner,
|
||||
app._("post_exception", "message").format(exp, format_exc()),
|
||||
app._("post_exception", "message").format(exc, format_exc()),
|
||||
)
|
||||
# rmtree(path.join(app.config['locations']['tmp'], tmp_dir), ignore_errors=True)
|
||||
return
|
||||
@ -253,14 +253,14 @@ async def send_content(app: PyroClient, http_session: ClientSession) -> None:
|
||||
str(app.config["posting"]["silent"]),
|
||||
)
|
||||
|
||||
except Exception as exp:
|
||||
except Exception as exc:
|
||||
logger.error(
|
||||
"Could not send content due to %s. Traceback: %s", exp, format_exc()
|
||||
"Could not send content due to %s. Traceback: %s", exc, format_exc()
|
||||
)
|
||||
if app.config["reports"]["error"]:
|
||||
await app.send_message(
|
||||
app.owner,
|
||||
app._("post_exception", "message").format(exp, format_exc()),
|
||||
app._("post_exception", "message").format(exc, format_exc()),
|
||||
)
|
||||
try:
|
||||
rmtree(
|
||||
|
@ -43,21 +43,21 @@ async def callback_query_yes(app: PyroClient, clb: CallbackQuery):
|
||||
show_alert=True,
|
||||
)
|
||||
return
|
||||
except SubmissionDuplicatesError as exp:
|
||||
except SubmissionDuplicatesError as exc:
|
||||
await clb.answer(
|
||||
text=app._("sub_duplicates_found", "callback", locale=user.locale),
|
||||
show_alert=True,
|
||||
)
|
||||
await clb.message.reply_text(
|
||||
app._("sub_media_duplicates_list", "message", locale=user.locale).format(
|
||||
"\n • ".join(exp.duplicates)
|
||||
"\n • ".join(exc.duplicates)
|
||||
),
|
||||
quote=True,
|
||||
)
|
||||
logger.info(
|
||||
"Submission with ID '%s' could not be accepted because of the duplicates: %s",
|
||||
fullclb[2],
|
||||
str(exp.duplicates),
|
||||
str(exc.duplicates),
|
||||
)
|
||||
return
|
||||
|
||||
@ -146,7 +146,7 @@ async def callback_query_no(app: PyroClient, clb: CallbackQuery):
|
||||
submission = await app.get_messages(
|
||||
db_entry["user"], db_entry["telegram"]["msg_id"]
|
||||
)
|
||||
except Exception as exp:
|
||||
except Exception as exc:
|
||||
await clb.answer(
|
||||
text=app._("sub_msg_unavail", "message", locale=user.locale),
|
||||
show_alert=True,
|
||||
|
@ -123,16 +123,16 @@ async def cmd_import(app: PyroClient, msg: Message):
|
||||
for name in handle.namelist()
|
||||
]
|
||||
_ = await asyncio.gather(*tasks)
|
||||
except Exception as exp:
|
||||
except Exception as exc:
|
||||
logger.error(
|
||||
"Could not import '%s' due to %s: %s",
|
||||
answer.document.file_name,
|
||||
exp,
|
||||
exc,
|
||||
format_exc(),
|
||||
)
|
||||
await answer.reply_text(
|
||||
app._("import_unpack_error", "message", locale=user.locale).format(
|
||||
exp, format_exc()
|
||||
exc, format_exc()
|
||||
)
|
||||
)
|
||||
return
|
||||
@ -165,12 +165,12 @@ async def cmd_import(app: PyroClient, msg: Message):
|
||||
compress=False,
|
||||
caption="queue",
|
||||
)
|
||||
except UnexpectedStatus as exp:
|
||||
except UnexpectedStatus as exc:
|
||||
logger.error(
|
||||
"Could not upload '%s' from '%s': %s",
|
||||
filename,
|
||||
Path(f"{app.config['locations']['tmp']}/{tmp_dir}"),
|
||||
exp,
|
||||
exc,
|
||||
)
|
||||
await msg.reply_text(
|
||||
app._(
|
||||
|
@ -237,16 +237,16 @@ async def get_submission(app: PyroClient, msg: Message):
|
||||
quote=True,
|
||||
)
|
||||
return
|
||||
except SubmissionDuplicatesError as exp:
|
||||
except SubmissionDuplicatesError as exc:
|
||||
await msg.reply_text(
|
||||
app._(
|
||||
"sub_media_duplicates_list", "message", locale=user.locale
|
||||
).format("\n • ".join(exp.duplicates)),
|
||||
).format("\n • ".join(exc.duplicates)),
|
||||
quote=True,
|
||||
)
|
||||
return
|
||||
except Exception as exp:
|
||||
await msg.reply_text(format_exc(), quote=True)
|
||||
except Exception as exc:
|
||||
await msg.reply_text(exc, quote=True)
|
||||
return
|
||||
elif (
|
||||
msg.from_user.id not in app.admins
|
||||
@ -270,12 +270,12 @@ async def get_submission(app: PyroClient, msg: Message):
|
||||
)
|
||||
)
|
||||
return
|
||||
except SubmissionDuplicatesError as exp:
|
||||
except SubmissionDuplicatesError as exc:
|
||||
await msg.reply_text(
|
||||
app._("sub_dup", "message", locale=user.locale), quote=True
|
||||
)
|
||||
return
|
||||
except Exception as exp:
|
||||
except Exception as exc:
|
||||
await app.send_message(
|
||||
app.owner,
|
||||
app._(
|
||||
|
Reference in New Issue
Block a user