-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use custom error instead of anyhow
- Loading branch information
Showing
5 changed files
with
76 additions
and
63 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,21 @@ | ||
//! Error types. | ||
use std::ops::Range; | ||
|
||
#[derive(Debug, thiserror::Error)] | ||
pub enum Error { | ||
#[error("invalid range {0:?}, start is larger than end")] | ||
InvalidRange(Range<usize>), | ||
|
||
#[error("invalid range {0:?}, original data is only {1} byte long")] | ||
DataLengthExceeded(Range<usize>, usize), | ||
|
||
#[error("could not replace range {0:?}, maybe parts of it were already replaced?")] | ||
MaybeAlreadyReplaced(Range<usize>), | ||
|
||
#[error("cannot replace slice of data that was already replaced")] | ||
AlreadyReplaced, | ||
|
||
#[error(transparent)] | ||
Utf8(#[from] std::string::FromUtf8Error), | ||
} |
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