mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-04-25 07:07:32 -04:00
refactor: rename && fix potential bugs
This commit is contained in:
parent
2d44a9a956
commit
328e0ac73a
4 changed files with 75 additions and 80 deletions
|
@ -25,11 +25,8 @@ impl std::convert::From<OTErrorCode> for OTError {
|
|||
}
|
||||
|
||||
impl OTError {
|
||||
pub fn new(code: OTErrorCode, msg: &str) -> OTError {
|
||||
Self {
|
||||
code,
|
||||
msg: msg.to_owned(),
|
||||
}
|
||||
pub fn new(code: OTErrorCode, msg: String) -> OTError {
|
||||
Self { code, msg }
|
||||
}
|
||||
|
||||
pub fn context<T: Debug>(mut self, error: T) -> Self {
|
||||
|
@ -76,6 +73,7 @@ pub enum OTErrorCode {
|
|||
Internal,
|
||||
PathNotFound,
|
||||
PathIsEmpty,
|
||||
UnexpectedEmpty,
|
||||
}
|
||||
|
||||
pub struct ErrorBuilder {
|
||||
|
@ -105,6 +103,6 @@ impl ErrorBuilder {
|
|||
}
|
||||
|
||||
pub fn build(mut self) -> OTError {
|
||||
OTError::new(self.code, &self.msg.take().unwrap_or_else(|| "".to_owned()))
|
||||
OTError::new(self.code, self.msg.take().unwrap_or_else(|| "".to_owned()))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue