From 2238522b27fc86c4dcc9c6efc2cb2d1e7060f9c5 Mon Sep 17 00:00:00 2001 From: rikkaka <793329010@qq.com> Date: Tue, 25 Jul 2023 23:47:04 +0800 Subject: [PATCH] add path info when error opening file --- polars/polars-lazy/polars-plan/src/logical_plan/builder.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/polars/polars-lazy/polars-plan/src/logical_plan/builder.rs b/polars/polars-lazy/polars-plan/src/logical_plan/builder.rs index c346b0b717a4..5561f42e10f2 100644 --- a/polars/polars-lazy/polars-plan/src/logical_plan/builder.rs +++ b/polars/polars-lazy/polars-plan/src/logical_plan/builder.rs @@ -253,7 +253,12 @@ impl LogicalPlanBuilder { try_parse_dates: bool, ) -> PolarsResult { let path = path.into(); - let mut file = std::fs::File::open(&path)?; + let mut file = std::fs::File::open(&path).map_err(|e| { + polars_err!( + Io: "error open file: '{:?}', {:?}", + path, e + ) + })?; let mut magic_nr = [0u8; 2]; file.read_exact(&mut magic_nr) .map_err(|_| polars_err!(NoData: "empty csv"))?;