-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Design error type. Fixes: #23 Signed-off-by: yaoyinnan <35447132+yaoyinnan@users.noreply.github.com>
- Loading branch information
Showing
10 changed files
with
91 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use thiserror::Error; | ||
use toml; | ||
|
||
pub type Result<T> = std::result::Result<T, ConfigError>; | ||
|
||
#[derive(Debug, Error)] | ||
pub enum ConfigError { | ||
#[error("parse toml error: {0}")] | ||
ParseToml(#[from] toml::de::Error), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
pub mod config; | ||
pub mod network; | ||
pub mod redis; | ||
pub mod server; | ||
|
||
use std::io; | ||
|
||
use crate::error::config::ConfigError; | ||
use crate::error::network::NetWorkError; | ||
use crate::error::redis::RedisError; | ||
use crate::error::server::ServerError; | ||
|
||
pub type Result<T> = std::result::Result<T, Error>; | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum Error { | ||
#[error("unexpected error: {0}")] | ||
Unexpected(String), | ||
|
||
#[error("error on network: {0}")] | ||
NetWork(#[from] NetWorkError), | ||
|
||
#[error("IO error: {0}")] | ||
IO(#[from] io::Error), | ||
|
||
#[error("error on config: {0}")] | ||
Config(#[from] ConfigError), | ||
|
||
#[error("error on redis: {0}")] | ||
Redis(#[from] RedisError), | ||
|
||
#[error("error on server: {0}")] | ||
Server(#[from] ServerError), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use thiserror::Error; | ||
|
||
pub type Result<T> = std::result::Result<T, NetWorkError>; | ||
|
||
#[derive(Debug, Error)] | ||
pub enum NetWorkError { | ||
#[error("error on network: {0}")] | ||
NetWork(String), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use thiserror::Error; | ||
|
||
pub type Result<T> = std::result::Result<T, ServerError>; | ||
|
||
#[derive(Debug, Error)] | ||
pub enum ServerError { | ||
#[error("can't not open db: {0}")] | ||
FailedOpenDB(String), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
pub mod defer; | ||
pub mod error; | ||
pub mod redis; |