jpreprocess_core/
error.rs1use lindera::error::LinderaError;
2
3use crate::{
4 accent_rule::AccentRuleParseError, ctype::CTypeParseError, pos::POSParseError,
5 pronunciation::PronunciationParseError,
6};
7
8#[derive(Debug, thiserror::Error)]
9pub enum JPreprocessError {
10 #[error("Io error: {0}")]
11 Io(#[from] std::io::Error),
12 #[error("Failed to fetch word from dictionary: {0}")]
13 DictionaryError(#[from] DictionaryError),
14 #[error("Lindera error: {0}")]
15 LinderaError(#[from] LinderaError),
16 #[error("Failed to parse pronunciation: {0}")]
17 PronunciationParseError(#[from] PronunciationParseError),
18 #[error("Failed to parse part of speech (POS): {0}")]
19 PartOfSpeechParseError(#[from] POSParseError),
20 #[error("Failed to parse conjugation type (CType): {0}")]
21 CTypeParseError(#[from] CTypeParseError),
22 #[error("Failed to parse conjugation form (CForm)")]
23 CFormParseError,
24 #[error("Failed to parse accent rule: {0}")]
25 AccentRuleParseError(#[from] AccentRuleParseError),
26 #[error("Provided mora size {0} is different from that of calculated from pronunciation {1}")]
27 MoraSizeMismatch(usize, usize),
28}
29
30#[derive(Debug, thiserror::Error)]
31pub enum DictionaryError {
32 #[error("Word with id {0} not found")]
33 IdNotFound(u32),
34 #[error("Failed to decode: {0}")]
35 FailDecode(#[from] Box<bincode::ErrorKind>),
36 #[error("The word is flagged as UserDictionary, but Lindera UserDictionary is empty")]
37 UserDictionaryNotProvided,
38 #[error("The word is flagged as UserDictionary, but UserDictionary mode is not set")]
39 UserDictionaryModeNotSet,
40}