-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
93 additions
and
27 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
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,61 @@ | ||
use thiserror::Error; | ||
|
||
/// wrapper around library error | ||
pub type Result<T> = std::result::Result<T, Error>; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum Error { | ||
#[error("storage error {0}")] | ||
Store(#[from] StorageError), | ||
#[error("network error {0}")] | ||
Network(#[from] NetworkError), | ||
#[error("file error {0}")] | ||
FileError(#[from] FileError), | ||
/// Some other error occurred. | ||
#[error("unknown error {0}")] | ||
Unknown(#[from] Box<dyn std::error::Error + Sync + Send>), | ||
} | ||
|
||
#[derive(Error, Debug)] | ||
pub enum NetworkError { | ||
#[error("opening connection failed")] | ||
OpenConnectionError, | ||
#[error("closing connection failed")] | ||
CloseConnectionError, | ||
#[error("listening on port = {0} failed")] | ||
ListenError(u8), | ||
} | ||
|
||
#[derive(Error, Debug)] | ||
pub enum StorageError { | ||
#[error("file is empty")] | ||
EmptyFile, | ||
#[error("File is potentially malicious")] | ||
MaliciousFile, | ||
#[error("error data integrity check failed!")] | ||
DataIntegrityError, | ||
#[error("storing log failed")] | ||
StoreError, | ||
#[error("log compaction failed")] | ||
CompactionError, | ||
#[error("log retrieval failed")] | ||
RetrieveError, | ||
} | ||
|
||
#[derive(Error, Debug)] | ||
pub enum FileError { | ||
#[error("write all operation failed")] | ||
WriteError, | ||
#[error("flush operation failed")] | ||
FlushError, | ||
#[error("creating file failed")] | ||
CreateError, | ||
#[error("opening file failed")] | ||
OpenError, | ||
#[error("reading file failed")] | ||
ReadError, | ||
#[error("removing file failed")] | ||
RemoveFileError, | ||
#[error("reading file metadata failed")] | ||
MetaDataError | ||
} |
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