Add a clearer error in case of bad file ids

This commit is contained in:
Dan 2020-11-28 14:58:24 +01:00
parent a0e0cbe477
commit 9f77fed181

View File

@ -52,7 +52,11 @@ def get_input_media_from_file_id(
file_id: str, file_id: str,
expected_file_type: FileType = None expected_file_type: FileType = None
) -> Union["raw.types.InputMediaPhoto", "raw.types.InputMediaDocument"]: ) -> Union["raw.types.InputMediaPhoto", "raw.types.InputMediaDocument"]:
try:
decoded = FileId.decode(file_id) decoded = FileId.decode(file_id)
except Exception:
raise ValueError(f'Failed to decode "{file_id}". The value does not represent an existing local file, '
f'HTTP URL, or valid file id.')
file_type = decoded.file_type file_type = decoded.file_type