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)", "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)", "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)", "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)", "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)", "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)", "rand 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -7,7 +7,6 @@ workspace = "../"
[dependencies] [dependencies]
rfc822_sanitizer = "0.3" rfc822_sanitizer = "0.3"
rayon = "0.8" rayon = "0.8"
hyper = "0.11"
reqwest = "0.8" reqwest = "0.8"
error-chain = "0.11" error-chain = "0.11"
log = "0.3" log = "0.3"

View File

@ -1,19 +1,13 @@
use diesel::migrations::RunMigrationsError;
use diesel::result; use diesel::result;
use rss; use rss;
use hyper;
use reqwest; use reqwest;
use log;
use std::io; use std::io;
error_chain! { error_chain! {
foreign_links { foreign_links {
LogError(log::SetLoggerError);
MigrationError(RunMigrationsError);
DieselResultError(result::Error); DieselResultError(result::Error);
RSSError(rss::Error); RSSError(rss::Error);
HyperError(hyper::error::Error);
ReqError(reqwest::Error); ReqError(reqwest::Error);
IoError(io::Error); IoError(io::Error);
} }

View File

@ -16,7 +16,6 @@ extern crate diesel;
extern crate diesel_codegen; extern crate diesel_codegen;
extern crate chrono; extern crate chrono;
extern crate hyper;
extern crate rayon; extern crate rayon;
extern crate reqwest; extern crate reqwest;
extern crate rfc822_sanitizer; extern crate rfc822_sanitizer;
@ -31,8 +30,8 @@ pub mod errors;
mod feedparser; mod feedparser;
mod schema; mod schema;
use diesel::migrations::RunMigrationsError;
use diesel::prelude::*; use diesel::prelude::*;
use errors::*;
use std::path::PathBuf; use std::path::PathBuf;
embed_migrations!("migrations/"); embed_migrations!("migrations/");
@ -64,18 +63,15 @@ lazy_static!{
}; };
} }
pub fn init() -> Result<()> { pub fn init() -> Result<(), RunMigrationsError> {
let conn = establish_connection(); let conn = establish_connection();
run_migration_on(&conn)?; run_migration_on(&conn)
Ok(())
} }
pub fn run_migration_on(connection: &SqliteConnection) -> Result<()> { pub fn run_migration_on(connection: &SqliteConnection) -> Result<(), RunMigrationsError> {
info!("Running DB Migrations..."); info!("Running DB Migrations...");
// embedded_migrations::run(&conn)?; embedded_migrations::run(connection)
embedded_migrations::run_with_output(connection, &mut std::io::stdout())?; // embedded_migrations::run_with_output(connection, &mut std::io::stdout())
Ok(())
} }
pub fn establish_connection() -> SqliteConnection { pub fn establish_connection() -> SqliteConnection {

View File

@ -4,10 +4,10 @@ use gdk_pixbuf::Pixbuf;
use std::fs; 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::dbqueries;
use hammond_data::models::Podcast;
use hammond_data::index_feed::Database;
use hammond_downloader::downloader;
use widgets::episode::episodes_listbox; use widgets::episode::episodes_listbox;
use podcasts_view::update_podcasts_view; use podcasts_view::update_podcasts_view;