Skip to content

Commit 9f77fed

Browse files
committed
Add a clearer error in case of bad file ids
1 parent a0e0cbe commit 9f77fed

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pyrogram/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ def get_input_media_from_file_id(
5252
file_id: str,
5353
expected_file_type: FileType = None
5454
) -> Union["raw.types.InputMediaPhoto", "raw.types.InputMediaDocument"]:
55-
decoded = FileId.decode(file_id)
55+
try:
56+
decoded = FileId.decode(file_id)
57+
except Exception:
58+
raise ValueError(f'Failed to decode "{file_id}". The value does not represent an existing local file, '
59+
f'HTTP URL, or valid file id.')
5660

5761
file_type = decoded.file_type
5862

0 commit comments

Comments
 (0)