summaryrefslogtreecommitdiff
path: root/src/errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/errors.rs')
-rw-r--r--src/errors.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/errors.rs b/src/errors.rs
new file mode 100644
index 0000000..bfb5606
--- /dev/null
+++ b/src/errors.rs
@@ -0,0 +1,21 @@
+use std::io;
+
+pub trait ToIOError {
+ fn to_io_error(self) -> io::Error;
+}
+
+impl ToIOError for git2::Error {
+ fn to_io_error(self) -> io::Error {
+ io::Error::new(io::ErrorKind::Other, self)
+ }
+}
+
+pub trait ToIOResult<T> {
+ fn to_io_result(self) -> io::Result<T>;
+}
+
+impl<T, E: ToIOError> ToIOResult<T> for std::result::Result<T, E> {
+ fn to_io_result(self) -> io::Result<T> {
+ self.map_err(|e| e.to_io_error())
+ }
+}