Skip to content

Missing error handling when reading files in path functions #15

@alexeev-prog

Description

@alexeev-prog

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

  • Replace all File.read! calls with File.read in the four modules listed above
  • Functions return ctx with an error key when file reading fails
  • send/2 checks for error key and returns {:error, {:file_error, reason}} without making API call
  • Update documentation to describe error handling behavior

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions