Class: X::ChunkedUploadFailed
- Inherits:
-
Uploads::Error
- Object
- Error
- Uploads::Error
- X::ChunkedUploadFailed
- Defined in:
- x-uploads/lib/x/uploads/chunked_upload_failed.rb
Overview
Error raised when a chunked upload is initialized, but its chunks cannot be appended or it cannot be finalized
The media is created, and its identifier given, once the upload is initialized, so the media is not lost to a chunk or a finalize that fails, as one the API answers with a server error, to media that can no longer be read, as a file deleted, closed, or shrunk once the upload was initialized cannot, or to any other error that ends the upload, as one the on_response hook of the client raises, or a thread for the chunks that cannot be started: the error holds the media the upload initialized, which names it by its identifier and its media key. The error that failed the upload is the cause, whose message the message ends with. A Timeout::Error, as Timeout.timeout raises around the upload, is raised as it is, so that a rescue of it still catches it, unless one raised with its class, as by Timeout.timeout(5, Timeout::Error), lands in the save_tokens of a refresh, which raises TokenReportFailed, holding the tokens. A TokenReportFailed, which a chunk or the finalize raises when save_tokens raised for the tokens of a refresh it made, is raised as it is too, rather than as this error, so that the rescue of it that stores the tokens it holds catches it around an upload as around any other request.
Instance Attribute Summary collapse
-
#media ⇒ UploadedMedia?
readonly
The media the upload initialized, which names it by its identifier.
Instance Method Summary collapse
-
#initialize(message = nil, media: nil) ⇒ ChunkedUploadFailed
constructor
Initialize the error with the media the upload initialized.
-
#to_s ⇒ String
The message, ending with why the upload could not be finished.
Constructor Details
#initialize(message = nil, media: nil) ⇒ ChunkedUploadFailed
Initialize the error with the media the upload initialized
The message is the one given, or else names the media by its identifier, when media that holds one was given.
73 74 75 76 |
# File 'x-uploads/lib/x/uploads/chunked_upload_failed.rb', line 73 def initialize( = nil, media: nil) @media = media.is_a?(Hash) ? UploadedMedia.new(media) : media super( || ["Media", media&.[]("id"), "was initialized, but its upload could not be finished"].compact.join(" ")) end |
Instance Attribute Details
#media ⇒ UploadedMedia? (readonly)
The media the upload initialized, which names it by its identifier
58 59 60 |
# File 'x-uploads/lib/x/uploads/chunked_upload_failed.rb', line 58 def media @media end |
Instance Method Details
#to_s ⇒ String
The message, ending with why the upload could not be finished
It ends with the message of the error that failed the upload, which is the cause, if there is one, whether the message was given or named the media.
87 |
# File 'x-uploads/lib/x/uploads/chunked_upload_failed.rb', line 87 def to_s = [super, cause&.].compact.join(": ") |