Skip to content

Commit

Permalink
Impl From<DuskBytesError> for Error
Browse files Browse the repository at this point in the history
Resolves #166
  • Loading branch information
moCello committed May 1, 2024
1 parent 3b2efb6 commit 07320ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Add `empty` method for the `Note` [#165]
- Add `From<DuskBytesError>` trait implementation for `Error` [#166]

## [0.27.0] - 2024-04-24

Expand Down Expand Up @@ -288,6 +289,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Canonical implementation shielded by feature.

<!-- ISSUES -->
[#166]: https://github.com/dusk-network/phoenix-core/issues/166
[#165]: https://github.com/dusk-network/phoenix-core/issues/165
[#156]: https://github.com/dusk-network/phoenix-core/issues/156
[#155]: https://github.com/dusk-network/phoenix-core/issues/155
Expand Down
14 changes: 14 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ impl From<AesError> for Error {
}
}

impl From<DuskBytesError> for Error {
fn from(err: DuskBytesError) -> Self {
match err {
DuskBytesError::InvalidData => Error::InvalidData,
DuskBytesError::BadLength { found, expected } => {
Error::BadLength(found, expected)
}
DuskBytesError::InvalidChar { ch, index } => {
Error::InvalidChar(ch, index)
}
}
}
}

impl From<Error> for DuskBytesError {
fn from(err: Error) -> Self {
match err {
Expand Down

0 comments on commit 07320ea

Please sign in to comment.