felipecrv commented on code in PR #3197: URL: https://github.com/apache/arrow-adbc/pull/3197#discussion_r2234076000
########## rust/driver_manager/src/error.rs: ########## @@ -0,0 +1,90 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use std::fmt; + +use adbc_core::error::Status; + +/// A Driver Manager error. +#[derive(Debug, PartialEq, Eq, Clone)] +pub enum Error { + Adbc(adbc_core::error::Error), + DynamicLibrary(String), + Other(String), +} Review Comment: I think we should figure out how to unify the `adbc_core` errors with the driver manager errors. It's weird to have an "adbc error" that needs to be extended to contain errors from the "adbc driver manager". It's all ADBC. ########## rust/driver_manager/src/error.rs: ########## @@ -0,0 +1,90 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use std::fmt; + +use adbc_core::error::Status; + +/// A Driver Manager error. +#[derive(Debug, PartialEq, Eq, Clone)] +pub enum Error { + Adbc(adbc_core::error::Error), + DynamicLibrary(String), + Other(String), +} + +/// Result type wrapping [Error]. +pub type Result<T> = std::result::Result<T, Error>; Review Comment: These aliases tend to not be worth the confusion they create. ########## rust/driver_manager/src/error.rs: ########## @@ -0,0 +1,90 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use std::fmt; + +use adbc_core::error::Status; + +/// A Driver Manager error. +#[derive(Debug, PartialEq, Eq, Clone)] +pub enum Error { + Adbc(adbc_core::error::Error), + DynamicLibrary(String), + Other(String), +} + +/// Result type wrapping [Error]. +pub type Result<T> = std::result::Result<T, Error>; Review Comment: You can `use std::result::Result;` and repeat `Result<T, Error>` everywhere. If either `T` or the `Error` have long names, then you can alias the T or error type name themselves. ########## rust/driver_manager/src/error.rs: ########## @@ -0,0 +1,90 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +use std::fmt; + +use adbc_core::error::Status; + +/// A Driver Manager error. +#[derive(Debug, PartialEq, Eq, Clone)] +pub enum Error { + Adbc(adbc_core::error::Error), + DynamicLibrary(String), + Other(String), +} + +/// Result type wrapping [Error]. +pub type Result<T> = std::result::Result<T, Error>; + +impl Error { + pub fn with_message_and_status(message: impl Into<String>, status: Status) -> Self { + (adbc_core::error::Error { + message: message.into(), + status, + vendor_code: 0, + sqlstate: [0; 5], + details: None, + }) + .into() + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Error::Adbc(e) => write!(f, "ADBC error: {e}"), + Error::DynamicLibrary(s) => write!(f, "Error with dynamic library: {s}"), + Error::Other(s) => write!(f, "Other error: {s}"), Review Comment: These prefixes to errors don't seem necessary, except maybe for the `Other` case where you might want to say "ADBC driver manager: {s}". -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org