expand on errors reported

This commit is contained in:
bunnie 2022-11-09 14:25:26 +08:00
parent e7e110ce76
commit c3ba30d55d

View file

@ -603,7 +603,9 @@ impl Pddb {
match response.code {
PddbRequestCode::NoErr => (),
PddbRequestCode::NotFound => return Err(Error::new(ErrorKind::NotFound, "dictionary not found")),
_ => return Err(Error::new(ErrorKind::Other, "Internal error")),
PddbRequestCode::AccessDenied => return Err(Error::new(ErrorKind::PermissionDenied, "concurrent operation in progress")),
PddbRequestCode::Uninit => return Err(Error::new(ErrorKind::ConnectionAborted, "Return code not set getting key count, server aborted?")),
_ => return Err(Error::new(ErrorKind::Other, "Internal error generating key count")),
};
// v2 key listing packs the key list into a larger [u8] field that should cut down on the number of messages
// required to list a large dictionary by about a factor of 50.
@ -625,7 +627,8 @@ impl Pddb {
match response.retcode {
ArchivedPddbRetcode::Ok => (),
ArchivedPddbRetcode::AccessDenied => return Err(Error::new(ErrorKind::PermissionDenied, "KeyList facility locked by another process, try again later")),
_ => return Err(Error::new(ErrorKind::Other, "Internal Error")),
ArchivedPddbRetcode::Uninit => return Err(Error::new(ErrorKind::ConnectionAborted, "Return code not set fetching list, server aborted?")),
_ => return Err(Error::new(ErrorKind::Other, "Internal Error fetching list")),
}
// the [u8] data is structured as a packed list of u8-len + u8 data slice. The max length of
// a PDDB key name is guaranteed to be shorter than a u8. If the length field is 0, then this