Except-Plugin
- author:syf20020816@outlook.com
- docName:Except-Plugin README
- createDate:20230814
- updateDate:20230814
- version:0.0.1
- email:syf20020816@outlook.com
LICEMSE
MIT
Except-Plugin Introduction
exception-plugin is a common exception in Rust, which helps developers better control their programs
Default Support Exception
- SuperException : 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.
- EasyException : Like SuperException, it also has no special features, but has two additional attributes: error file and error line.
- NullPointerException
- ArrayIndexOutOfBoundsException
- UnSupportedOpException : UnsupportedOpException is a broad error that includes many possible causes, such as lack of permissions, inaccessible files, IO exceptions ...
- SQLException : SQLException is an error that may be caused when accessing or manipulating a database, such as no table, empty table data, and no columns ...
QuickStart
use Error;
use ;
use PathBuf;
use ;
Define a self Exception
use Error;
use ;
use Deref;
use Duration;
use ;
/// # step1 : create a new exception
///
/// mut contain 4 param!:
/// - code
/// - msg
/// - level
/// - timestamp
/// # step2 : use macro to impl Exception for MyException
/// if you wanna impl Exception trait , you must impl Error,Debug,Display,as followings:
/// ```rust
/// impl Error for MyException {}
/// impl Debug for MyException {}
/// impl Display for MyException {}
/// impl Exception for MyException { // fn ... }
/// ```
/// it is very complicated , so you can use exception_impl! and display_err_impl!
display_err_impl!;
exception_impl!;
/// # step3 : impl the other param for define Exception
/// actually , now it is enough
/// but you need to continue!!!
/// # step4 : create a builder for define Exception
/// builder is quite simple and you should add a param : `e_type: Exceptions`
/// # step5 : add builder_impl! macro for Define Exception
builder_impl!;
/// # step6 : impl NewFrom and FromBuilder
/// # step 7: test