You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by uw...@apache.org on 2018/04/05 07:17:55 UTC

[arrow] branch master updated: ARROW-2396: [Rust] Unify Rust Errors

This is an automated email from the ASF dual-hosted git repository.

uwe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 045470c  ARROW-2396: [Rust] Unify Rust Errors
045470c is described below

commit 045470c3879fd05f528dbe68f2c2299b2ebba105
Author: Maximilian Roos <m...@maxroos.com>
AuthorDate: Thu Apr 5 09:17:49 2018 +0200

    ARROW-2396: [Rust] Unify Rust Errors
    
    Currently there are two Error items - one Enum and one Struct. This unifies them under a single ArrowError Enum.
    
    Let me know any feedback
    
    Author: Maximilian Roos <m...@maxroos.com>
    
    Closes #1836 from maxim-lian/unify-errors and squashes the following commits:
    
    1f38bbd <Maximilian Roos> cargo fmt
    ac60505 <Maximilian Roos> unify errors to a single Enum
---
 rust/src/datatypes.rs |  6 +-----
 rust/src/error.rs     | 17 ++++-------------
 rust/src/memory.rs    |  8 +++++---
 3 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/rust/src/datatypes.rs b/rust/src/datatypes.rs
index 8589a84..1e1afe6 100644
--- a/rust/src/datatypes.rs
+++ b/rust/src/datatypes.rs
@@ -18,11 +18,7 @@
 use std::fmt;
 use serde_json;
 use serde_json::Value;
-
-#[derive(Debug, Clone, PartialEq)]
-pub enum ArrowError {
-    ParseError(String),
-}
+use super::error::ArrowError;
 
 #[derive(Debug, Clone, PartialEq)]
 pub enum DataType {
diff --git a/rust/src/error.rs b/rust/src/error.rs
index d1fb742..6a342e0 100644
--- a/rust/src/error.rs
+++ b/rust/src/error.rs
@@ -15,17 +15,8 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use std::convert::*;
-
-#[derive(Debug, Clone)]
-pub struct Error {
-    msg: String,
-}
-
-impl From<&'static str> for Error where {
-    fn from(msg: &'static str) -> Self {
-        Error {
-            msg: String::from(msg),
-        }
-    }
+#[derive(Debug, Clone, PartialEq)]
+pub enum ArrowError {
+    MemoryError(String),
+    ParseError(String),
 }
diff --git a/rust/src/memory.rs b/rust/src/memory.rs
index 2e5aaf0..41d4c53 100644
--- a/rust/src/memory.rs
+++ b/rust/src/memory.rs
@@ -18,17 +18,19 @@
 use libc;
 use std::mem;
 
-use super::error::Error;
+use super::error::ArrowError;
 
 const ALIGNMENT: usize = 64;
 
-pub fn allocate_aligned(size: i64) -> Result<*const u8, Error> {
+pub fn allocate_aligned(size: i64) -> Result<*const u8, ArrowError> {
     unsafe {
         let mut page: *mut libc::c_void = mem::uninitialized();
         let result = libc::posix_memalign(&mut page, ALIGNMENT, size as usize);
         match result {
             0 => Ok(mem::transmute::<*mut libc::c_void, *const u8>(page)),
-            _ => Err(Error::from("Failed to allocate memory")),
+            _ => Err(ArrowError::MemoryError(format!(
+                "Failed to allocate memory"
+            ))),
         }
     }
 }

-- 
To stop receiving notification emails like this one, please contact
uwe@apache.org.