Ji-Xinyou commented on code in PR #1861:
URL: 
https://github.com/apache/incubator-opendal/pull/1861#discussion_r1159979483


##########
bindings/c/src/error.rs:
##########
@@ -0,0 +1,203 @@
+// 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::ffi::CString;
+use std::os::raw::{c_char, c_void};
+
+use ::opendal as od;
+
+/// The wrapper type for opendal's error, wrapped because of the
+/// orphan rule
+pub(crate) struct OpendalError(pub(crate) od::Error);
+
+/// The C-compatible error type enum used in c bindings.
+/// NOTICE: the type definition of [`ErrorNo`] should be aligned with
+///         [`od::ErrorKind`]
+#[repr(C)]
+pub enum opendal_errno {
+    /// returning it back. For example, s3 returns an internal service error.
+    Unexpected,
+    /// Underlying service doesn't support this operation.
+    Unsupported,
+    /// The config for backend is invalid.
+    ConfigInvalid,
+    /// The given path is not found.
+    NotFound,
+    /// The given path doesn't have enough permission for this operation
+    PermissionDenied,
+    /// The given path is a directory.
+    IsADirectory,
+    /// The given path is not a directory.
+    NotADirectory,
+    /// The given path already exists thus we failed to the specified 
operation on it.
+    AlreadyExists,
+    /// Requests that sent to this path is over the limit, please slow down.
+    RateLimited,
+    /// The given file paths are same.
+    IsSameFile,
+    /// Unknown error, since [`opendal::ErrorKind`] is nonexhaustive
+    UnknownError,
+    /// NullPtr error, meaning that a provided pointer which need to be 
dereferenced is null
+    NullPtr,

Review Comment:
   I am not sure about your meaning of isolate the errors with code.
   
   I mean if another error `someerr` were added in the future in the `core`, 
how do we use that error code to express `someerr`.



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

Reply via email to