{"record":{"id":"fccda95c87afaa1d","repo":"pola-rs/polars","slug":"0","errorCode":null,"errorMessage":"{0}","messagePattern":"\\{0\\}","errorType":"error_code","errorClass":"PyPolarsErr","httpStatus":null,"severity":"error","filePath":"pyo3-polars/pyo3-polars/src/error.rs","lineNumber":15,"sourceCode":"use std::fmt::{Debug, Formatter};\n\nuse polars::prelude::PolarsError;\nuse pyo3::create_exception;\nuse pyo3::exceptions::{\n    PyAssertionError, PyException, PyIOError, PyIndexError, PyRuntimeError, PyValueError,\n};\nuse pyo3::prelude::*;\nuse thiserror::Error;\n\n#[derive(Error)]\npub enum PyPolarsErr {\n    #[error(transparent)]\n    Polars(#[from] PolarsError),\n    #[error(\"{0}\")]\n    Other(String),\n}\n\nimpl std::convert::From<PyPolarsErr> for PyErr {\n    fn from(err: PyPolarsErr) -> PyErr {\n        fn convert(err: PolarsError) -> PyErr {\n            match err {\n                PolarsError::AssertionError(error) => PyAssertionError::new_err(error.to_string()),\n                PolarsError::ComputeError(err) => ComputeError::new_err(err.to_string()),\n                PolarsError::NoData(err) => NoDataError::new_err(err.to_string()),\n                PolarsError::ShapeMismatch(err) => ShapeError::new_err(err.to_string()),\n                PolarsError::SchemaMismatch(err) => SchemaError::new_err(err.to_string()),\n                PolarsError::IO { error, .. } => PyIOError::new_err(error.to_string()),\n                PolarsError::OutOfBounds(err) => PyIndexError::new_err(err.to_string()),\n                PolarsError::InvalidOperation(err) => PyValueError::new_err(err.to_string()),\n                PolarsError::Duplicate(err) => DuplicateError::new_err(err.to_string()),\n                PolarsError::ColumnNotFound(err) => ColumnNotFound::new_err(err.to_string()),\n                PolarsError::SchemaFieldNotFound(err) => {","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/pyo3-polars/pyo3-polars/src/error.rs#L1-L33","documentation":"PyPolarsErr::Other is the escape hatch in pyo3-polars for arbitrary error strings: it wraps a plain String and its Display (used as the Python error message) is just the inner text. Any Rust code raising PyPolarsErr::Other(msg) surfaces msg verbatim to Python.","triggerScenarios":"Rust-side polars/interop code calls PyPolarsErr::Other(format!(...)) for errors that do not map to a PolarsError variant, so the Python exception message equals whatever string was formatted at the call site.","commonSituations":"Seeing an opaque one-line message from pyo3-polars-backed operations (e.g. custom Rust plugins, value conversion failures) with no structured error type behind it; debugging plugins that use Other for all errors.","solutions":["Read the message text directly — it is the raw Rust-side error string; locate the call site raising Other with that text.","In Rust, prefer mapping to specific PolarsError variants or thiserror enums instead of Other for actionable errors.","Include context (parameter names, values) in the format! when raising Other so the Python message is actionable."],"exampleFix":"// before\nPyPolarsErr::Other(format!(\"bad value\"))\n// after\nPyPolarsErr::Other(format!(\"bad value for column '{}': got {:?}\", name, value))","handlingStrategy":"try-catch","validationCode":"# Python: validate inputs before they reach the Rust boundary\nif not isinstance(value, (str, int, float)):\n    raise TypeError(f\"unsupported value type for rust interop: {type(value)}\")","typeGuard":null,"tryCatchPattern":"try:\n    result = rust_backed_call(args)\nexcept Exception as e:  # PyPolarsErr::Other surfaces as generic error\n    raise RuntimeError(f\"pyo3-polars op failed: {e}\") from e","preventionTips":["Validate inputs on the Python side before crossing into Rust.","In Rust, reserve Other for truly unexpected conditions and include full context in the message.","Grep the Rust code for PyPolarsErr::Other call sites when debugging an opaque message."],"tags":["rust","pyo3","polars","error-wrapping"],"backgroundTag":"api-error-response","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}