Class: X::ChunkedUploadFailed
- Inherits:
-
Uploader::Error
- Object
- Error
- Uploader::Error
- X::ChunkedUploadFailed
- Defined in:
- x-uploader/lib/x/uploader/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.
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.
65 66 67 68 |
# File 'x-uploader/lib/x/uploader/chunked_upload_failed.rb', line 65 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
50 51 52 |
# File 'x-uploader/lib/x/uploader/chunked_upload_failed.rb', line 50 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.
79 |
# File 'x-uploader/lib/x/uploader/chunked_upload_failed.rb', line 79 def to_s = [super, cause&.].compact.join(": ") |