Skip to content

Commit 0674458

Browse files
authored
feat(rust): make error-related types public (#396)
* feat(rust): make error-related types public Signed-off-by: Luka Peschke <luka.peschke@toucantoco.com> * fix(deps): loosen upper constraint on `log` crate Signed-off-by: Luka Peschke <luka.peschke@toucantoco.com> --------- Signed-off-by: Luka Peschke <luka.peschke@toucantoco.com>
1 parent 67905dd commit 0674458

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ arrow-pyarrow = { version = "^56.1.0", optional = true }
3131
arrow-schema = { version = "^56.1.0", optional = true }
3232
calamine = { version = "^0.30.1", features = ["dates"] }
3333
chrono = { version = "^0.4.42", default-features = false }
34-
log = "^0.4.28"
34+
log = "^0.4"
3535
polars-core = { version = ">=0.50", default-features = false, features = [
3636
"dtype-date",
3737
"dtype-datetime",

src/error.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::types::idx_or_name::IdxOrName;
22
use calamine::XlsxError;
33
use std::{error::Error, fmt::Display};
44

5+
/// The kind of a fastexcel error.
56
#[derive(Debug)]
67
pub enum FastExcelErrorKind {
78
UnsupportedColumnTypeCombination(String),
@@ -49,6 +50,10 @@ impl Display for FastExcelErrorKind {
4950
}
5051
}
5152

53+
/// A `fastexcel` error.
54+
///
55+
/// Contains a kind and a context. Use the `Display` trait to format the
56+
/// error message with its context.
5257
#[derive(Debug)]
5358
pub struct FastExcelError {
5459
pub kind: FastExcelErrorKind,
@@ -109,7 +114,7 @@ impl From<XlsxError> for FastExcelError {
109114
}
110115
}
111116

112-
pub(crate) type FastExcelResult<T> = Result<T, FastExcelError>;
117+
pub type FastExcelResult<T> = Result<T, FastExcelError>;
113118

114119
impl<T> ErrorContext for FastExcelResult<T> {
115120
fn with_context<S: ToString, F>(self, ctx_fn: F) -> Self

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ use pyo3::prelude::*;
1313
use types::excelsheet::{CellError, CellErrors};
1414

1515
pub use data::{FastExcelColumn, FastExcelSeries};
16+
use error::ErrorContext;
17+
pub use error::{FastExcelError, FastExcelErrorKind, FastExcelResult};
1618
pub use types::{
1719
ColumnInfo, ColumnNameFrom, DType, DTypeCoercion, DTypeFrom, DTypes, ExcelReader, ExcelSheet,
1820
ExcelTable, IdxOrName, LoadSheetOrTableOptions, SelectedColumns, SheetVisible, SkipRows,
1921
};
2022

21-
use crate::error::{ErrorContext, FastExcelResult};
22-
2323
/// Reads an excel file and returns an object allowing to access its sheets, tables, and a bit of metadata.
2424
/// This is a wrapper around `ExcelReader::try_from_path`.
2525
pub fn read_excel<S: AsRef<str> + Display>(path: S) -> FastExcelResult<ExcelReader> {

0 commit comments

Comments
 (0)