E568 Remove Error::BadData · ITCSsDeveloper/rust-postgres@6abcf0e · GitHub
Skip to content

Commit 6abcf0e

Browse files
committed
Remove Error::BadData
1 parent aa6f558 commit 6abcf0e

5 files changed

Lines changed: 9 additions & 12 deletions

File tree

src/error.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ pub enum Error {
124124
WasNull,
125125
/// The server returned an unexpected response
126126
BadResponse,
127-
/// The server provided data that the client could not parse
128-
BadData,
129127
}
130128

131129
impl fmt::Display for Error {
@@ -150,7 +148,6 @@ impl error::Error for Error {
150148
Error::InvalidColumn => "Invalid column",
151149
Error::WasNull => "The value was NULL",
152150
Error::BadResponse => "The server returned an unexpected response",
153-
Error::BadData => "The server provided data that the client could not parse",
154151
}
155152
}
156153

src/types/json.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ impl RawFromSql for json::Json {
88
if let Type::Jsonb = *ty {
99
// We only support version 1 of the jsonb binary format
1010
if try!(raw.read_u8()) != 1 {
11-
return Err(Error::BadData);
11+
return Err(Error::BadResponse);
1212
}
1313
}
14-
json::Json::from_reader(raw).map_err(|_| Error::BadData)
14+
json::Json::from_reader(raw).map_err(|_| Error::BadResponse)
1515
}
1616
}
1717

src/types/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl RawFromSql for Vec<u8> {
368368

369369
impl RawFromSql for String {
370370
fn raw_from_sql<R: Reader>(_: &Type, raw: &mut R) -> Result<String> {
371-
String::from_utf8(try!(raw.read_to_end())).map_err(|_| Error::BadData)
371+
String::from_utf8(try!(raw.read_to_end())).map_err(|_| Error::BadResponse)
372372
}
373373
}
374374

@@ -387,7 +387,7 @@ impl RawFromSql for IpAddr {
387387
let _is_cidr = try!(raw.read_u8());
388388
let nb = try!(raw.read_u8());
389389
if nb > 16 {
390-
return Err(Error::BadData);
390+
return Err(Error::BadResponse);
391391
}
392392
let mut buf = [0u8; 16];
393393
try!(raw.read_at_least(nb as usize, &mut buf));
@@ -403,7 +403,7 @@ impl RawFromSql for IpAddr {
403403
try!(buf.read_be_u16()),
404404
try!(buf.read_be_u16()),
405405
try!(buf.read_be_u16()))),
406-
_ => Err(Error::BadData),
406+
_ => Err(Error::BadResponse),
407407
}
408408
}
409409
}
@@ -458,7 +458,7 @@ impl FromSql for Option<HashMap<String, Option<String>>> {
458458
let key = try!(rdr.read_exact(key_len as usize));
459459
let key = match String::from_utf8(key) {
460460
Ok(key) => key,
461-
Err(_) => return Err(Error::BadData),
461+
Err(_) => return Err(Error::BadResponse),
462462
};
463463

464464
let val_len = try!(rdr.read_be_i32());
@@ -468,7 +468,7 @@ impl FromSql for Option<HashMap<String, Option<String>>> {
468468
let val = try!(rdr.read_exact(val_len as usize));
469469
match String::from_utf8(val) {
470470
Ok(val) => Some(val),
471-
Err(_) => return Err(Error::BadData),
471+
Err(_) => return Err(Error::BadResponse),
472472
}
473473
};
474474

src/types/uuid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ impl RawFromSql for Uuid {
99
fn raw_from_sql<R: Reader>(_: &Type, raw: &mut R) -> Result<Uuid> {
1010
match Uuid::from_bytes(&*try!(raw.rea AB3E d_to_end())) {
1111
Some(u) => Ok(u),
12-
None => Err(Error::BadData),
12+
None => Err(Error::BadResponse),
1313
}
1414
}
1515
}

src/ugh_privacy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub fn dberror_new_connect<T>(fields: Vec<(u8, String)>) -> result::Result<T, Co
100100
pub fn dberror_new<T>(fields: Vec<(u8, String)>) -> Result<T> {
101101
match dberror_new_raw(fields) {
102102
Ok(err) => Err(Error::DbError(err)),
103-
Err(()) => Err(Error::BadData),
103+
Err(()) => Err(Error::BadResponse),
104104
}
105105
}
106106

0 commit comments

Comments
 (0)