Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,31 @@ pub enum AsyncHttpRangeReaderError {
MemoryMapError(#[source] Arc<std::io::Error>),

/// Error from `http-content-range`
#[error("Invalid Content-Range header: {0}")]
#[error("invalid Content-Range header: {0}")]
ContentRangeParser(String),

/// The server returned an invalid range response
#[error(
"request and response range mismatch, \
expected {expected_start}-{expected_end_inclusive}/{expected_complete_length}, \
got {actual_start}-{actual_end_inclusive}/{actual_complete_length}"
)]
RangeMismatch {
expected_start: u64,
expected_end_inclusive: u64,
expected_complete_length: usize,
actual_start: u64,
actual_end_inclusive: u64,
actual_complete_length: u64,
},

/// The server returned more bytes than the range request asked for
#[error("range response returned more than the expected {expected} bytes")]
ResponseTooLong { expected: u64 },

/// The server returned fewer bytes than the range request asked for
#[error("expected {expected} bytes from range response, got {actual}")]
ResponseTooShort { expected: u64, actual: u64 },
}

impl From<std::io::Error> for AsyncHttpRangeReaderError {
Expand Down
Loading