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::fmt::Display;

/// Error type for semantic conversion errors.
///
/// For example when converting [crate::spec::ClassLikeTypeName] to [crate::spec::KotlinFile].
#[derive(Debug)]
pub struct SemanticConversionError {
    message: String
}

impl SemanticConversionError {

    pub(crate) fn new(message: &str) -> Self {
        SemanticConversionError {
            message: message.to_string()
        }
    }
}

impl Display for SemanticConversionError {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(f, "{}", self.message)
    }
}

impl std::error::Error for SemanticConversionError {}