alexandreyc commented on code in PR #1725:
URL: https://github.com/apache/arrow-adbc/pull/1725#discussion_r1568355944


##########
rust2/core/src/error.rs:
##########
@@ -0,0 +1,166 @@
+// 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.
+
+//! Error, status and result types.
+
+use std::{ffi::NulError, fmt::Display};
+
+use arrow::error::ArrowError;
+
+/// Status of an operation.
+#[derive(Debug, Copy, Clone, PartialEq, Eq)]
+pub enum Status {
+    /// No error.
+    Ok,
+    /// An unknown error occurred.
+    Unknown,
+    /// The operation is not implemented or supported.
+    NotImplemented,
+    /// A requested resource was not found.
+    NotFound,
+    /// A requested resource already exists.
+    AlreadyExists,
+    /// The arguments are invalid, likely a programming error.
+    /// For instance, they may be of the wrong format, or out of range.
+    InvalidArguments,
+    /// The preconditions for the operation are not met, likely a programming 
error.
+    /// For instance, the object may be uninitialized, or may have not
+    /// been fully configured.
+    InvalidState,
+    /// Invalid data was processed (not a programming error).
+    /// For instance, a division by zero may have occurred during query
+    /// execution.
+    InvalidData,
+    /// The database's integrity was affected.
+    /// For instance, a foreign key check may have failed, or a uniqueness
+    /// constraint may have been violated.
+    Integrity,
+    /// An error internal to the driver or database occurred.
+    Internal,
+    /// An I/O error occurred.
+    /// For instance, a remote service may be unavailable.
+    IO,
+    /// The operation was cancelled, not due to a timeout.
+    Cancelled,
+    /// The operation was cancelled due to a timeout.
+    Timeout,
+    /// Authentication failed.
+    Unauthenticated,
+    /// The client is not authorized to perform the given operation.
+    Unauthorized,
+}
+
+/// An ADBC error.
+#[derive(Debug, PartialEq, Eq)]
+pub struct Error {
+    /// The error message.
+    pub message: String,
+    /// The status of the operation.
+    pub status: Status,
+    /// A vendor-specific error code, if applicable.
+    pub vendor_code: i32,
+    /// A SQLSTATE error code, if provided, as defined by the SQL:2003 
standard.
+    /// If not set, it should be set to `\0\0\0\0\0`.
+    pub sqlstate: [i8; 5],
+    /// Additional metadata. Introduced in ADBC 1.1.0.
+    pub details: Option<Vec<(String, Vec<u8>)>>,

Review Comment:
   1. I think we cannot use a map here because the C API provides 
`AdbcErrorGetDetail(error, index)` which access the error detail by index 
rather than key... I'm not able to find any map usage in the Go implementation 
for this.
   
   2. I would prefer to keep the `Option` here because `None` encodes the fact 
that this field does not exist in ADBC 1.0.0 rather than an empty collection. 
To me, it conveys a better semantics. No?



-- 
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

Reply via email to