Error types cleanup.

This commit is contained in:
Jordan Petridis 2017-11-05 15:36:54 +02:00
parent 7b5bca2162
commit 36271afcdd
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
5 changed files with 9 additions and 21 deletions

1
Cargo.lock generated
View File

@ -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)",

View File

@ -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"

View File

@ -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);
}

View File

@ -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 {

View File

@ -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;