paleolimbot commented on code in PR #3381:
URL: https://github.com/apache/arrow-adbc/pull/3381#discussion_r2312763206
##########
rust/core/src/error.rs:
##########
@@ -153,3 +157,59 @@ impl From<std::ffi::IntoStringError> for Error {
error.into()
}
}
+
+impl TryFrom<AdbcStatusCode> for Status {
+ type Error = Error;
+
+ fn try_from(value: AdbcStatusCode) -> Result<Self> {
+ match value {
+ constants::ADBC_STATUS_OK => Ok(Status::Ok),
+ constants::ADBC_STATUS_UNKNOWN => Ok(Status::Unknown),
+ constants::ADBC_STATUS_NOT_IMPLEMENTED =>
Ok(Status::NotImplemented),
+ constants::ADBC_STATUS_NOT_FOUND => Ok(Status::NotFound),
+ constants::ADBC_STATUS_ALREADY_EXISTS => Ok(Status::AlreadyExists),
+ constants::ADBC_STATUS_INVALID_ARGUMENT =>
Ok(Status::InvalidArguments),
+ constants::ADBC_STATUS_INVALID_STATE => Ok(Status::InvalidState),
+ constants::ADBC_STATUS_INVALID_DATA => Ok(Status::InvalidData),
+ constants::ADBC_STATUS_INTEGRITY => Ok(Status::Integrity),
+ constants::ADBC_STATUS_INTERNAL => Ok(Status::Internal),
+ constants::ADBC_STATUS_IO => Ok(Status::IO),
+ constants::ADBC_STATUS_CANCELLED => Ok(Status::Cancelled),
+ constants::ADBC_STATUS_TIMEOUT => Ok(Status::Timeout),
+ constants::ADBC_STATUS_UNAUTHENTICATED =>
Ok(Status::Unauthenticated),
+ constants::ADBC_STATUS_UNAUTHORIZED => Ok(Status::Unauthorized),
+ v => Err(Error::with_message_and_status(
+ format!("Unknown status code: {v}"),
+ Status::InvalidData,
+ )),
Review Comment:
I think this is OK (although Unknown might make more sense. I don't think
we're adding more status codes anytime soon but it could happen if a future
error code from a future driver makes its way through this TryFrom).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]