Sha256: 23b7c5842b3873008ff06a5ac05591082c95e818eef9adc2bfcc59c56c286376

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 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 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

1 entries across 1 versions & 1 rubygems

Version Path
polars-df-0.5.0 ext/polars/src/error.rs