ferroui_base/
render_target_not_ready_exception.rs1use std::error::Error;
2use std::fmt;
3use std::rc::Rc;
4
5#[derive(Clone, Debug)]
7pub struct RenderTargetNotReadyException {
8 message: Option<String>,
9 inner_exception: Option<Rc<dyn Error>>,
10}
11
12impl RenderTargetNotReadyException {
13 pub fn new() -> Self {
15 Self { message: None, inner_exception: None }
16 }
17
18 pub fn new_with_message(message: impl Into<String>) -> Self {
20 Self { message: Some(message.into()), inner_exception: None }
21 }
22
23 pub fn new_with_inner_exception(inner_exception: Rc<dyn Error>) -> Self {
25 Self { message: None, inner_exception: Some(inner_exception) }
26 }
27
28 pub fn new_with_message_and_inner_exception(message: impl Into<String>, inner_exception: Rc<dyn Error>) -> Self {
31 Self { message: Some(message.into()), inner_exception: Some(inner_exception) }
32 }
33
34 pub fn message(&self) -> &str {
37 self.message.as_deref().unwrap_or("Exception of type 'FerroUI.RenderTargetNotReadyException' was thrown.")
38 }
39
40 pub fn inner_exception(&self) -> Option<&Rc<dyn Error>> {
42 self.inner_exception.as_ref()
43 }
44}
45
46impl Default for RenderTargetNotReadyException {
47 fn default() -> Self {
48 Self::new()
49 }
50}
51
52impl fmt::Display for RenderTargetNotReadyException {
53 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54 f.write_str(self.message())
55 }
56}
57
58impl Error for RenderTargetNotReadyException {
59 fn source(&self) -> Option<&(dyn Error + 'static)> {
60 self.inner_exception.as_deref()
61 }
62}