From 36271afcddffa28a98856b01f38e49ba1fdfee4d Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Sun, 5 Nov 2017 15:36:54 +0200 Subject: [PATCH] Error types cleanup. --- Cargo.lock | 1 - hammond-data/Cargo.toml | 1 - hammond-data/src/errors.rs | 6 ------ hammond-data/src/lib.rs | 16 ++++++---------- hammond-gtk/src/widgets/podcast.rs | 6 +++--- 5 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a4c5526..4a39fab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -547,7 +547,6 @@ dependencies = [ "diesel_codegen 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", "dotenv 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.11.6 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/hammond-data/Cargo.toml b/hammond-data/Cargo.toml index edf33a7..8221571 100644 --- a/hammond-data/Cargo.toml +++ b/hammond-data/Cargo.toml @@ -7,7 +7,6 @@ workspace = "../" [dependencies] rfc822_sanitizer = "0.3" rayon = "0.8" -hyper = "0.11" reqwest = "0.8" error-chain = "0.11" log = "0.3" diff --git a/hammond-data/src/errors.rs b/hammond-data/src/errors.rs index 4c3f2ca..9446dff 100644 --- a/hammond-data/src/errors.rs +++ b/hammond-data/src/errors.rs @@ -1,19 +1,13 @@ -use diesel::migrations::RunMigrationsError; use diesel::result; use rss; -use hyper; use reqwest; -use log; use std::io; error_chain! { foreign_links { - LogError(log::SetLoggerError); - MigrationError(RunMigrationsError); DieselResultError(result::Error); RSSError(rss::Error); - HyperError(hyper::error::Error); ReqError(reqwest::Error); IoError(io::Error); } diff --git a/hammond-data/src/lib.rs b/hammond-data/src/lib.rs index 549fb7f..8ae8d31 100644 --- a/hammond-data/src/lib.rs +++ b/hammond-data/src/lib.rs @@ -16,7 +16,6 @@ extern crate diesel; extern crate diesel_codegen; extern crate chrono; -extern crate hyper; extern crate rayon; extern crate reqwest; extern crate rfc822_sanitizer; @@ -31,8 +30,8 @@ pub mod errors; mod feedparser; mod schema; +use diesel::migrations::RunMigrationsError; use diesel::prelude::*; -use errors::*; use std::path::PathBuf; embed_migrations!("migrations/"); @@ -64,18 +63,15 @@ lazy_static!{ }; } -pub fn init() -> Result<()> { +pub fn init() -> Result<(), RunMigrationsError> { let conn = establish_connection(); - run_migration_on(&conn)?; - - Ok(()) + run_migration_on(&conn) } -pub fn run_migration_on(connection: &SqliteConnection) -> Result<()> { +pub fn run_migration_on(connection: &SqliteConnection) -> Result<(), RunMigrationsError> { info!("Running DB Migrations..."); - // embedded_migrations::run(&conn)?; - embedded_migrations::run_with_output(connection, &mut std::io::stdout())?; - Ok(()) + embedded_migrations::run(connection) + // embedded_migrations::run_with_output(connection, &mut std::io::stdout()) } pub fn establish_connection() -> SqliteConnection { diff --git a/hammond-gtk/src/widgets/podcast.rs b/hammond-gtk/src/widgets/podcast.rs index 681b8e0..4a92b29 100644 --- a/hammond-gtk/src/widgets/podcast.rs +++ b/hammond-gtk/src/widgets/podcast.rs @@ -4,10 +4,10 @@ use gdk_pixbuf::Pixbuf; use std::fs; -use hammond_data::models::Podcast; -use hammond_downloader::downloader; -use hammond_data::index_feed::Database; use hammond_data::dbqueries; +use hammond_data::models::Podcast; +use hammond_data::index_feed::Database; +use hammond_downloader::downloader; use widgets::episode::episodes_listbox; use podcasts_view::update_podcasts_view;