Improve exception clarity for message parsing failure (#3029)

This commit is contained in:
Joshua Coales 2021-04-17 18:10:33 +01:00 committed by GitHub
parent a376faa3a8
commit 3001b620ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,7 +83,11 @@ class MessageParseMethods:
if not parse_mode:
return message, []
original_message = message
message, msg_entities = parse_mode.parse(message)
if original_message and not message and not msg_entities:
raise ValueError("Failed to parse message")
for i in reversed(range(len(msg_entities))):
e = msg_entities[i]
if isinstance(e, types.MessageEntityTextUrl):