# **Easy-Err**
### **简介 Introduce**
- 方便地将各种不同类型的错误统一为**同种错误**,实现了简单易用的报告功能。
It is easy to unify various types of errors into the same error, enabling easy-to-use reporting.
- 本文件中出现的所有英文使用**微软翻译**翻译,如有问题不关我事。(doge)
All English language that appears in this document is translated using Microsoft Translator, if there is no problem. (doge)
---
### **怎么报告BUG How to report Bugs**
- **作者邮箱(Email):** [C3407087852@outlook.com](C3407087852@outlook.com)
---
### **Todo**
- [x] 错误转换
- [x] Result处理
- [ ] 想到再说...
---
### **例子 Example**
#### 例子1 (Ex.1)
基础用法 (How to use me basically.)
```
use easy_err::Error;
// 自定义一个错误 (Custom an error.)
let custom_err = Error::custom("Here is a custom error.");
// 将错误写入日志文件 (Write the error into a file.)
custom_err.log_to("./log.txt");
```
`log.txt`中的输出 (Output in `log.txt`):
```
error:
time: <ErrorTime>
msg: Here is a custom error.
```
---
#### 例子2 (Ex.2)
进阶用法 (How to use me more advanced.)
**警告:** 这还是一个实验性功能,作者本人暂未想清楚此处该如何实现,欢迎报告此功能的Bug。
**Warning:** This is still an experimental feature, and the author himself has not yet figured out how to implement it here, so please report bugs in this feature.
```
use std::fs;
use easy_err::{Error, ErrResult};
// 定义一个返回 Result<T, easy_err::Error> 的函数 (Define a function that returns the Result.)
fn test() -> Result<(), Error> {
fs::File::open("An obvious mistake.")?;
Ok(())
}
// 调用 test() (Call the function.)
test().panic();
```