1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use std::{num::ParseIntError, path::PathBuf};

use thiserror::Error;

#[derive(Error, Debug)]
pub enum CoreError {
    #[error("{0}")]
    IOError(#[from] std::io::Error),

    #[error("Filename format does not match: {0}")]
    FileNameFormatDoesNotMatch(PathBuf),

    #[error("Couldn't parse language id: {0}")]
    LangIdParseError(#[from] ParseIntError),

    #[error("Filename does not exist for path: {0}")]
    FileNameDoesNotExistError(PathBuf),

    #[error("File name is not a valid utf8: {0}")]
    Utf8ValidityError(PathBuf),

    #[error("QuestionId: {0} does not exist")]
    QuestionIdDoesNotExist(String),
}

pub type CoreResult<T> = Result<T, CoreError>;