mirror of
https://github.com/n08i40k/schedule-parser-rusted.git
synced 2025-12-06 17:57:47 +03:00
refactor: refactor providers code
This commit is contained in:
38
providers/provider-engels-polytechnic/src/parser/error.rs
Normal file
38
providers/provider-engels-polytechnic/src/parser/error.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
use derive_more::{Display, Error, From};
|
||||
use crate::parser::worksheet::CellPos;
|
||||
|
||||
#[derive(Clone, Debug, Display, Error)]
|
||||
#[display("'{data}' at {pos}")]
|
||||
pub struct ErrorCell {
|
||||
pub pos: CellPos,
|
||||
pub data: String,
|
||||
}
|
||||
|
||||
impl ErrorCell {
|
||||
pub fn new(row: u32, column: u32, data: &str) -> Self {
|
||||
Self {
|
||||
pos: CellPos { row, column },
|
||||
data: data.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Display, Error, From)]
|
||||
pub enum Error {
|
||||
#[from]
|
||||
BadXls(calamine::XlsError),
|
||||
|
||||
#[display("No work sheets found.")]
|
||||
NoWorkSheets,
|
||||
|
||||
#[display("There is no data on work sheet boundaries.")]
|
||||
UnknownWorkSheetRange,
|
||||
|
||||
#[display("Failed to read lesson start and end from {_0}.")]
|
||||
NoLessonBoundaries(ErrorCell),
|
||||
|
||||
#[display("No start and end times matching the lesson (at {_0}) was found.")]
|
||||
LessonTimeNotFound(CellPos),
|
||||
}
|
||||
|
||||
pub type Result<T> = core::result::Result<T, Error>;
|
||||
Reference in New Issue
Block a user