Motivations
Currently, functions like Photo.path/2, Document.path/2, Sticker.path/2, and Video.path/2 use File.read!/1. If the specified file does not exist or cannot be read, the bot crashes with a File.Error exception. This brings down the entire GenServer process in production, making the bot unstable.
Expected behavior: failed file reads should return an error tuple without crashing.
- Would you like to implement this feature? [y]
Solution
Replace File.read! with File.read and propagate the error through the builder pipeline.
Affected modules:
TelegramEx.Builder.Document
TelegramEx.Builder.Photo
TelegramEx.Builder.Sticker
TelegramEx.Builder.Video
Readiness criteria
Motivations
Currently, functions like
Photo.path/2,Document.path/2,Sticker.path/2, andVideo.path/2useFile.read!/1. If the specified file does not exist or cannot be read, the bot crashes with aFile.Errorexception. This brings down the entire GenServer process in production, making the bot unstable.Expected behavior: failed file reads should return an error tuple without crashing.
Solution
Replace
File.read!withFile.readand propagate the error through the builder pipeline.Affected modules:
TelegramEx.Builder.DocumentTelegramEx.Builder.PhotoTelegramEx.Builder.StickerTelegramEx.Builder.VideoReadiness criteria
File.read!calls withFile.readin the four modules listed abovectxwith an error key when file reading failssend/2checks for error key and returns{:error, {:file_error, reason}}without making API call