Skip to main content

ferroui_base/
ferro_internal_exception.rs

1use std::fmt;
2
3/// Exception signifying an internal logic error in the framework.
4///
5/// The framework itself reports such an error with a panic (porting guide:
6/// programmer errors panic); the type names the error where it is passed on
7/// as a value.
8#[derive(Clone, Debug, PartialEq, Eq)]
9pub struct FerroInternalException {
10    message: String,
11}
12
13impl FerroInternalException {
14    /// Creates the exception with the given message.
15    pub fn new(message: impl Into<String>) -> Self {
16        Self { message: message.into() }
17    }
18
19    /// The message that describes the error.
20    pub fn message(&self) -> &str {
21        &self.message
22    }
23}
24
25impl fmt::Display for FerroInternalException {
26    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27        f.write_str(&self.message)
28    }
29}
30
31impl std::error::Error for FerroInternalException {}