File tree 5 files changed +12
-7
lines changed
5 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ impl oio::Read for Cursor {
84
84
Some ( n) if n >= 0 => n as u64 ,
85
85
_ => {
86
86
return Poll :: Ready ( Err ( Error :: new (
87
- ErrorKind :: Unexpected ,
87
+ ErrorKind :: InvalidInput ,
88
88
"invalid seek to a negative or overflowing position" ,
89
89
) ) )
90
90
}
@@ -127,7 +127,7 @@ impl oio::BlockingRead for Cursor {
127
127
Some ( n) if n >= 0 => n as u64 ,
128
128
_ => {
129
129
return Err ( Error :: new (
130
- ErrorKind :: Unexpected ,
130
+ ErrorKind :: InvalidInput ,
131
131
"invalid seek to a negative or overflowing position" ,
132
132
) )
133
133
}
Original file line number Diff line number Diff line change 90
90
91
91
match base. checked_add ( offset) {
92
92
Some ( n) if n < 0 => Err ( Error :: new (
93
- ErrorKind :: Unexpected ,
93
+ ErrorKind :: InvalidInput ,
94
94
"invalid seek to a negative or overflowing position" ,
95
95
) ) ,
96
96
Some ( n) => {
@@ -104,7 +104,7 @@ where
104
104
Ok ( self . offset - self . start )
105
105
}
106
106
None => Err ( Error :: new (
107
- ErrorKind :: Unexpected ,
107
+ ErrorKind :: InvalidInput ,
108
108
"invalid seek to a negative or overflowing position" ,
109
109
) ) ,
110
110
}
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ impl<A: Accessor> RangeReader<A> {
114
114
Some ( n) if n >= 0 => n as u64 ,
115
115
_ => {
116
116
return Err ( Error :: new (
117
- ErrorKind :: Unexpected ,
117
+ ErrorKind :: InvalidInput ,
118
118
"invalid seek to a negative or overflowing position" ,
119
119
) )
120
120
}
Original file line number Diff line number Diff line change 93
93
94
94
match base. checked_add ( offset) {
95
95
Some ( n) if n < 0 => Poll :: Ready ( Err ( Error :: new (
96
- ErrorKind :: Unexpected ,
96
+ ErrorKind :: InvalidInput ,
97
97
"invalid seek to a negative or overflowing position" ,
98
98
) ) ) ,
99
99
Some ( n) => {
@@ -109,7 +109,7 @@ where
109
109
Poll :: Ready ( Ok ( self . offset - self . start ) )
110
110
}
111
111
None => Poll :: Ready ( Err ( Error :: new (
112
- ErrorKind :: Unexpected ,
112
+ ErrorKind :: InvalidInput ,
113
113
"invalid seek to a negative or overflowing position" ,
114
114
) ) ) ,
115
115
}
Original file line number Diff line number Diff line change @@ -99,6 +99,10 @@ pub enum ErrorKind {
99
99
/// - Users expected to read 1024 bytes, but service returned less bytes.
100
100
/// - Service expected to write 1024 bytes, but users write less bytes.
101
101
ContentIncomplete ,
102
+ /// The input is invalid.
103
+ ///
104
+ /// For example, user try to seek to a negative position
105
+ InvalidInput ,
102
106
}
103
107
104
108
impl ErrorKind {
@@ -130,6 +134,7 @@ impl From<ErrorKind> for &'static str {
130
134
ErrorKind :: ConditionNotMatch => "ConditionNotMatch" ,
131
135
ErrorKind :: ContentTruncated => "ContentTruncated" ,
132
136
ErrorKind :: ContentIncomplete => "ContentIncomplete" ,
137
+ ErrorKind :: InvalidInput => "InvalidInput" ,
133
138
}
134
139
}
135
140
}
You can’t perform that action at this time.
0 commit comments