Skip to content

Commit

Permalink
Merge pull request #1132 from spacejam/tyler_0.34
Browse files Browse the repository at this point in the history
0.34
  • Loading branch information
spacejam authored Jul 23, 2020
2 parents 8331943 + 18c405c commit fe13c8f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Unreleased
# 0.34

## Improvements

* #1132 implemented From<sled::Error> for io::Error to
reduce friction in some situations.

## Breaking Changes

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sled"
version = "0.33.0"
version = "0.34.0"
authors = ["Tyler Neely <[email protected]>"]
description = "a modern embedded database"
license = "MIT/Apache-2.0"
Expand Down
32 changes: 32 additions & 0 deletions src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,38 @@ impl From<io::Error> for Error {
}
}

impl From<Error> for io::Error {
fn from(error: Error) -> io::Error {
use self::Error::*;
use std::io::ErrorKind;
match error {
Io(ioe) => ioe,
CollectionNotFound(name) =>
io::Error::new(
ErrorKind::NotFound,
format!("collection not found: {:?}", name),
),
Unsupported(why) => io::Error::new(
ErrorKind::InvalidInput,
format!("operation not supported: {:?}", why),
),
ReportableBug(what) => io::Error::new(
ErrorKind::Other,
format!("unexpected bug! please report this bug at <github.rs/spacejam/sled>: {:?}", what),
),
Corruption { .. } => io::Error::new(
ErrorKind::InvalidData,
format!("corruption encountered: {:?}", error),
),
#[cfg(feature = "failpoints")]
FailPoint => io::Error::new(
ErrorKind::Other,
"failpoint"
),
}
}
}

impl StdError for Error {}

impl Display for Error {
Expand Down

0 comments on commit fe13c8f

Please sign in to comment.