mirror of
https://github.com/n08i40k/schedule-parser-rusted.git
synced 2025-12-06 09:47:50 +03:00
feat(error): add error for unknown lesson type
This commit is contained in:
@@ -17,6 +17,9 @@ pub enum Error {
|
|||||||
|
|
||||||
#[display("No start and end times matching the lesson (at {_0}) was found.")]
|
#[display("No start and end times matching the lesson (at {_0}) was found.")]
|
||||||
LessonTimeNotFound(CellPos),
|
LessonTimeNotFound(CellPos),
|
||||||
|
|
||||||
|
#[display("Unknown lesson type `{type}` at {pos}")]
|
||||||
|
UnknownLessonType { pos: CellPos, r#type: String },
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Result<T> = core::result::Result<T, Error>;
|
pub type Result<T> = core::result::Result<T, Error>;
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ fn parse_lesson(
|
|||||||
name,
|
name,
|
||||||
mut subgroups,
|
mut subgroups,
|
||||||
r#type: lesson_type,
|
r#type: lesson_type,
|
||||||
} = parse_name_and_subgroups(&name)?;
|
} = parse_name_and_subgroups(&name, row, group_column)?;
|
||||||
|
|
||||||
{
|
{
|
||||||
let cabinets: Vec<String> = parse_cabinets(
|
let cabinets: Vec<String> = parse_cabinets(
|
||||||
@@ -363,7 +363,7 @@ struct ParsedLessonName {
|
|||||||
|
|
||||||
//noinspection GrazieInspection
|
//noinspection GrazieInspection
|
||||||
/// Getting the "pure" name of the lesson and list of teachers from the text of the lesson cell.
|
/// Getting the "pure" name of the lesson and list of teachers from the text of the lesson cell.
|
||||||
fn parse_name_and_subgroups(text: &str) -> Result<ParsedLessonName> {
|
fn parse_name_and_subgroups(text: &str, row: u32, column: u32) -> Result<ParsedLessonName> {
|
||||||
// Части названия пары:
|
// Части названия пары:
|
||||||
// 1. Само название.
|
// 1. Само название.
|
||||||
// 2. Список преподавателей и подгрупп.
|
// 2. Список преподавателей и подгрупп.
|
||||||
@@ -475,12 +475,21 @@ fn parse_name_and_subgroups(text: &str) -> Result<ParsedLessonName> {
|
|||||||
if result.is_none() {
|
if result.is_none() {
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
sentry::capture_message(
|
sentry::capture_message(
|
||||||
&format!("Не удалось угадать тип пары '{}'!", extra),
|
&Error::UnknownLessonType {
|
||||||
|
r#type: extra.to_string(),
|
||||||
|
pos: CellPos::new(row, column),
|
||||||
|
},
|
||||||
sentry::Level::Warning,
|
sentry::Level::Warning,
|
||||||
);
|
);
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
log::warn!("Не удалось угадать тип пары '{}'!", extra);
|
log::warn!(
|
||||||
|
"{}",
|
||||||
|
Error::UnknownLessonType {
|
||||||
|
r#type: extra.to_string(),
|
||||||
|
pos: CellPos::new(row, column),
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|||||||
Reference in New Issue
Block a user