diff --git a/crates/polars-error/src/lib.rs b/crates/polars-error/src/lib.rs index 18272183401d..4c7ad7724b95 100644 --- a/crates/polars-error/src/lib.rs +++ b/crates/polars-error/src/lib.rs @@ -411,12 +411,12 @@ on startup."#.trim_start()) $dtype, ) }; - (assert_eq = $lhs:expr, $rhs:expr) => { + (assertion_error = $objects:expr, $detail:expr, $lhs:expr, $rhs:expr) => { $crate::polars_err!( - AssertionError: "equality assertion failed: {} != {}", - $lhs, $rhs + AssertionError: "{} are different ({})\n[left]: {}\n[right]: {}", + $objects, $detail, $lhs, $rhs ) - } + }; } #[macro_export] diff --git a/crates/polars-python/src/error.rs b/crates/polars-python/src/error.rs index f73f6bb79d3c..8c3a20751bc2 100644 --- a/crates/polars-python/src/error.rs +++ b/crates/polars-python/src/error.rs @@ -12,7 +12,7 @@ use pyo3::prelude::*; use pyo3::PyTypeInfo; use crate::exceptions::{ - AssertionError, CategoricalRemappingWarning, ColumnNotFoundError, ComputeError, DuplicateError, + CategoricalRemappingWarning, ColumnNotFoundError, ComputeError, DuplicateError, InvalidOperationError, MapWithoutReturnDtypeWarning, NoDataError, OutOfBoundsError, SQLInterfaceError, SQLSyntaxError, SchemaError, SchemaFieldNotFoundError, ShapeError, StringCacheMismatchError, StructFieldNotFoundError, @@ -68,7 +68,9 @@ impl From for PyErr { use PyPolarsErr::*; match err { Polars(err) => match err { - PolarsError::AssertionError(err) => AssertionError::new_err(err.to_string()), + PolarsError::AssertionError(err) => { + pyo3::exceptions::PyAssertionError::new_err(err.to_string()) + }, PolarsError::ColumnNotFound(name) => ColumnNotFoundError::new_err(name.to_string()), PolarsError::ComputeError(err) => ComputeError::new_err(err.to_string()), PolarsError::Duplicate(err) => DuplicateError::new_err(err.to_string()), diff --git a/crates/polars-python/src/exceptions.rs b/crates/polars-python/src/exceptions.rs index 8eec706f3ee2..3edbd6c71de2 100644 --- a/crates/polars-python/src/exceptions.rs +++ b/crates/polars-python/src/exceptions.rs @@ -5,7 +5,6 @@ use pyo3::exceptions::{PyException, PyWarning}; // Errors create_exception!(polars.exceptions, PolarsError, PyException); -create_exception!(polars.exceptions, AssertionError, PolarsError); create_exception!(polars.exceptions, ColumnNotFoundError, PolarsError); create_exception!(polars.exceptions, ComputeError, PolarsError); create_exception!(polars.exceptions, DuplicateError, PolarsError);