Skip to content
Merged
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
4 changes: 2 additions & 2 deletions core/src/raw/oio/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl oio::Read for Cursor {
Some(n) if n >= 0 => n as u64,
_ => {
return Poll::Ready(Err(Error::new(
ErrorKind::Unexpected,
ErrorKind::InvalidInput,
"invalid seek to a negative or overflowing position",
)))
}
Expand Down Expand Up @@ -127,7 +127,7 @@ impl oio::BlockingRead for Cursor {
Some(n) if n >= 0 => n as u64,
_ => {
return Err(Error::new(
ErrorKind::Unexpected,
ErrorKind::InvalidInput,
"invalid seek to a negative or overflowing position",
))
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/raw/oio/into_blocking_reader/from_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ where

match base.checked_add(offset) {
Some(n) if n < 0 => Err(Error::new(
ErrorKind::Unexpected,
ErrorKind::InvalidInput,
"invalid seek to a negative or overflowing position",
)),
Some(n) => {
Expand All @@ -104,7 +104,7 @@ where
Ok(self.offset - self.start)
}
None => Err(Error::new(
ErrorKind::Unexpected,
ErrorKind::InvalidInput,
"invalid seek to a negative or overflowing position",
)),
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/raw/oio/into_reader/by_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl<A: Accessor> RangeReader<A> {
Some(n) if n >= 0 => n as u64,
_ => {
return Err(Error::new(
ErrorKind::Unexpected,
ErrorKind::InvalidInput,
"invalid seek to a negative or overflowing position",
))
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/raw/oio/into_reader/from_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ where

match base.checked_add(offset) {
Some(n) if n < 0 => Poll::Ready(Err(Error::new(
ErrorKind::Unexpected,
ErrorKind::InvalidInput,
"invalid seek to a negative or overflowing position",
))),
Some(n) => {
Expand All @@ -109,7 +109,7 @@ where
Poll::Ready(Ok(self.offset - self.start))
}
None => Poll::Ready(Err(Error::new(
ErrorKind::Unexpected,
ErrorKind::InvalidInput,
"invalid seek to a negative or overflowing position",
))),
}
Expand Down
5 changes: 5 additions & 0 deletions core/src/types/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ pub enum ErrorKind {
/// - Users expected to read 1024 bytes, but service returned less bytes.
/// - Service expected to write 1024 bytes, but users write less bytes.
ContentIncomplete,
/// The input is invalid.
///
/// For example, user try to seek to a negative position
InvalidInput,
}

impl ErrorKind {
Expand Down Expand Up @@ -130,6 +134,7 @@ impl From<ErrorKind> for &'static str {
ErrorKind::ConditionNotMatch => "ConditionNotMatch",
ErrorKind::ContentTruncated => "ContentTruncated",
ErrorKind::ContentIncomplete => "ContentIncomplete",
ErrorKind::InvalidInput => "InvalidInput",
}
}
}
Expand Down