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:
@@ -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_); }
|
||||
|
||||
|
Reference in New Issue
Block a user