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

use native_db::db_type;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum DbErr {
    #[error("NativeDbError encountered {0}")]
    NativeDbError(#[from] db_type::Error),

    #[error("Could not create topic {0}")]
    TopicCreateError(String),

    #[error("FrontEndQuestionIdParseError: {0}")]
    FrontEndQuestionIdParseError(#[from] ParseIntError),

    #[error("Question not found: {0}")]
    QuestionsNotFoundInDb(String),

    #[error("Topic not found: {0}")]
    TopicsNotFoundInDb(String),
}

pub type DBResult<T> = Result<T, DbErr>;