1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-12 08:12:22 +01:00

[online_image] Improve error handling (#8212)

This commit is contained in:
guillempages
2025-02-11 12:12:13 +01:00
committed by GitHub
parent 8b7aa4c110
commit c9e7562aff
7 changed files with 35 additions and 13 deletions

View File

@@ -29,8 +29,12 @@ class ImageDecoder {
* @brief Initialize the decoder.
*
* @param download_size The total number of bytes that need to be downloaded for the image.
* @return int Returns 0 on success, a {@see DecodeError} value in case of an error.
*/
virtual void prepare(size_t download_size) { this->download_size_ = download_size; }
virtual int prepare(size_t download_size) {
this->download_size_ = download_size;
return 0;
}
/**
* @brief Decode a part of the image. It will try reading from the buffer.
@@ -83,10 +87,7 @@ class ImageDecoder {
class DownloadBuffer {
public:
DownloadBuffer(size_t size) : size_(size) {
this->buffer_ = this->allocator_.allocate(size);
this->reset();
}
DownloadBuffer(size_t size);
virtual ~DownloadBuffer() { this->allocator_.deallocate(this->buffer_, this->size_); }