summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJustus Winter <justus@pep-project.org>2017-12-13 15:18:21 +0100
committerJustus Winter <justus@pep-project.org>2017-12-13 17:20:04 +0100
commit2e1fd08111776e3fa078bb50075ded9de181d6f9 (patch)
tree69a0086cdd7ed13b13bd08ddf059917d638b70f3 /core
parent1e60568f020bd4f1cba2627784b849a9db293c52 (diff)
core: Improve error handling.
- Add and use Result and Error type.
Diffstat (limited to 'core')
-rw-r--r--core/src/lib.rs22
1 files changed, 20 insertions, 2 deletions
diff --git a/core/src/lib.rs b/core/src/lib.rs
index bbdd520f..12085a11 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -44,7 +44,7 @@ impl Context {
/// `domain` should uniquely identify your application, it is
/// strongly suggested to use a reversed fully qualified domain
/// name that is associated with your application.
- pub fn new(domain: &str) -> io::Result<Self> {
+ pub fn new(domain: &str) -> Result<Self> {
Self::configure(domain).build()
}
@@ -97,7 +97,7 @@ pub struct Config(Context);
impl Config {
/// Finalizes the configuration and returns a `Context`.
- pub fn build(self) -> io::Result<Context> {
+ pub fn build(self) -> Result<Context> {
let c = self.0;
fs::create_dir_all(c.home())?;
Ok(c)
@@ -125,3 +125,21 @@ impl Config {
self.0.lib = PathBuf::new().join(lib);
}
}
+
+/* Error handling. */
+
+/// Result type for Sequoia.
+pub type Result<T> = ::std::result::Result<T, Error>;
+
+/// Errors for Sequoia.
+#[derive(Debug)]
+pub enum Error {
+ /// An `io::Error` occured.
+ IoError(io::Error),
+}
+
+impl From<io::Error> for Error {
+ fn from(error: io::Error) -> Self {
+ Error::IoError(error)
+ }
+}