Sha256: b1e0acedde6e7c4956d6bc60430345f42b56fd09c234a4f0b6f8c6a8bd7c4446

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

use magnus::exception;
use magnus::Error;
use polars::error::ArrowError;
use polars::prelude::PolarsError;

pub struct RbPolarsErr {}

impl RbPolarsErr {
    // convert to Error instead of Self
    pub fn from(e: PolarsError) -> Error {
        Error::new(exception::runtime_error(), e.to_string())
    }

    pub fn arrow(e: ArrowError) -> Error {
        Error::new(exception::runtime_error(), e.to_string())
    }

    pub fn io(e: std::io::Error) -> Error {
        Error::new(exception::runtime_error(), e.to_string())
    }

    pub fn other(message: String) -> Error {
        Error::new(exception::runtime_error(), message)
    }

    pub fn todo() -> Error {
        Error::new(exception::runtime_error(), "not implemented yet")
    }
}

pub struct RbValueError {}

impl RbValueError {
    pub fn new_err(message: String) -> Error {
        Error::new(exception::arg_error(), message)
    }
}

pub struct ComputeError {}

impl ComputeError {
    pub fn new_err(message: String) -> Error {
        Error::new(exception::runtime_error(), message)
    }
}

#[macro_export]
macro_rules! raise_err(
    ($msg:expr, $err:ident) => {{
        Err(PolarsError::$err($msg.into())).map_err(RbPolarsErr::from)?;
        unreachable!()
    }}
);

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
polars-df-0.4.0 ext/polars/src/error.rs
polars-df-0.3.1 ext/polars/src/error.rs