pub struct SuperException { /* private fields */ }
Expand description
§Supper Exception
It is the top-level implementation of all exceptions , you can get this from all more specific exceptions’ recover param
Although it is the parent of all exceptions, it is actually the lowest level exception
§example
use std::error::Error;
use except_plugin::{SuperBuilder, SuperException, ExceptionFactory, Exceptions, SuperBuilderImpl, ExceptionLevel, Exception, DerefException};
pub fn test_super_exception() {
// use ExceptionFactory -> get SuperBuilder -> build SuperException
let e = ExceptionFactory::new::<SuperException, SuperBuilder>()
.set_code(1006)
.set_msg("super builder")
.set_level(ExceptionLevel::Fatal)
.build();
dbg!(e);
}
pub fn test_super_exception_result() -> Result<(), Box<dyn Error>> {
// build a exception
let mut e = ExceptionFactory::new::<SuperException, SuperBuilder>()
.set_code(1006)
.set_msg("super builder")
.set_level(ExceptionLevel::Fatal)
.build();
e.set_msg("this is a super exception!");
let e = e.deref_mut_exception();
Err(Box::new(e))
}
fn main() {
test_super_exception();
let e = test_super_exception_result();
match e {
Ok(_) => {}
Err(err) => {
println!("{:?}", err.description());
}
}
}
Trait Implementations§
Source§impl Clone for SuperException
impl Clone for SuperException
Source§fn clone(&self) -> SuperException
fn clone(&self) -> SuperException
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SuperException
impl Debug for SuperException
Source§impl Default for SuperException
impl Default for SuperException
Source§impl DerefException for SuperException
impl DerefException for SuperException
fn deref_mut_exception(&mut self) -> Self
Source§impl Display for SuperException
impl Display for SuperException
Source§impl Error for SuperException
impl Error for SuperException
Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
Source§impl Exception for SuperException
impl Exception for SuperException
fn code(&self) -> u32
fn msg(&self) -> &str
fn level(&self) -> ExceptionLevel
fn set_code(&mut self, code: u32)
fn set_level(&mut self, level: ExceptionLevel)
fn set_msg(&mut self, msg: &str)
fn get_type(&self) -> Exceptions
fn timestamp(&self) -> Duration
Source§impl FromBuilder for SuperException
impl FromBuilder for SuperException
Source§type Output = SuperException
type Output = SuperException
exception type
Source§type Input = SuperBuilder
type Input = SuperBuilder
builder type
fn from_builder(builder: &Self::Input) -> Self::Output
Source§impl NewFrom for SuperException
impl NewFrom for SuperException
Source§impl PartialEq for SuperException
impl PartialEq for SuperException
Source§impl SuperBuilderImpl<SuperException> for SuperBuilder
impl SuperBuilderImpl<SuperException> for SuperBuilder
fn new() -> Self
fn code(&self) -> u32
fn msg(&self) -> &str
fn level(&self) -> ExceptionLevel
fn set_code(&mut self, code: u32) -> &mut Self
fn set_msg(&mut self, msg: &str) -> &mut Self
fn set_level(&mut self, level: ExceptionLevel) -> &mut Self
fn exception_type(&self) -> Exceptions
fn timestamp(&self) -> Duration
fn build(&mut self) -> SuperException
impl StructuralPartialEq for SuperException
Auto Trait Implementations§
impl Freeze for SuperException
impl RefUnwindSafe for SuperException
impl Send for SuperException
impl Sync for SuperException
impl Unpin for SuperException
impl UnwindSafe for SuperException
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more