diff --git a/core/src/raw/oio/cursor.rs b/core/src/raw/oio/cursor.rs index 7ce2247d3364..363719a3ffd0 100644 --- a/core/src/raw/oio/cursor.rs +++ b/core/src/raw/oio/cursor.rs @@ -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", ))) } @@ -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", )) } diff --git a/core/src/raw/oio/into_blocking_reader/from_fd.rs b/core/src/raw/oio/into_blocking_reader/from_fd.rs index 51cf534725e7..ac01b33e7562 100644 --- a/core/src/raw/oio/into_blocking_reader/from_fd.rs +++ b/core/src/raw/oio/into_blocking_reader/from_fd.rs @@ -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) => { @@ -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", )), } diff --git a/core/src/raw/oio/into_reader/by_range.rs b/core/src/raw/oio/into_reader/by_range.rs index e26af95a7539..cb761523bda8 100644 --- a/core/src/raw/oio/into_reader/by_range.rs +++ b/core/src/raw/oio/into_reader/by_range.rs @@ -114,7 +114,7 @@ impl RangeReader { Some(n) if n >= 0 => n as u64, _ => { return Err(Error::new( - ErrorKind::Unexpected, + ErrorKind::InvalidInput, "invalid seek to a negative or overflowing position", )) } diff --git a/core/src/raw/oio/into_reader/from_fd.rs b/core/src/raw/oio/into_reader/from_fd.rs index c6a15231a2a4..1c3e02d5519c 100644 --- a/core/src/raw/oio/into_reader/from_fd.rs +++ b/core/src/raw/oio/into_reader/from_fd.rs @@ -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) => { @@ -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", ))), } diff --git a/core/src/types/error.rs b/core/src/types/error.rs index 88453c7708db..b530c16a179e 100644 --- a/core/src/types/error.rs +++ b/core/src/types/error.rs @@ -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 { @@ -130,6 +134,7 @@ impl From for &'static str { ErrorKind::ConditionNotMatch => "ConditionNotMatch", ErrorKind::ContentTruncated => "ContentTruncated", ErrorKind::ContentIncomplete => "ContentIncomplete", + ErrorKind::InvalidInput => "InvalidInput", } } }