Remove anyhow.

This commit is contained in:
LukeMathWalker 2020-10-18 14:13:27 +01:00
parent cfb11a798d
commit ff99488030
5 changed files with 4 additions and 18 deletions

8
Cargo.lock generated
View file

@ -334,12 +334,6 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "anyhow"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1fd36ffbb1fb7c834eac128ea8d0e310c5aeb635548f9d58861e1308d46e71c"
[[package]]
name = "arc-swap"
version = "0.4.7"
@ -529,7 +523,6 @@ version = "0.1.0"
dependencies = [
"actix-rt",
"actix-web",
"anyhow",
"chrono",
"config",
"reqwest",
@ -545,7 +538,6 @@ version = "0.1.0"
dependencies = [
"actix-rt",
"actix-web",
"anyhow",
"chrono",
"config",
"lazy_static",

View file

@ -19,7 +19,6 @@ tokio = "0.2.22"
serde = "1.0.115"
config = { version = "0.10.1", default-features = false, features = ["yaml"] }
sqlx = { version = "0.4.0-beta.1", default-features = false, features = [ "runtime-tokio", "macros", "postgres", "uuid", "chrono", "migrate"] }
anyhow = "1.0.32"
uuid = { version = "0.8.1", features = ["v4"] }
chrono = "0.4.15"

View file

@ -1,16 +1,14 @@
use anyhow::Context;
use chapter03_1::configuration::get_configuration;
use chapter03_1::startup::run;
use sqlx::postgres::PgPool;
use std::net::TcpListener;
#[actix_rt::main]
async fn main() -> Result<(), anyhow::Error> {
async fn main() -> std::io::Result<()> {
let configuration = get_configuration().expect("Failed to read configuration.");
let connection_pool = PgPool::connect(&configuration.database.connection_string())
.await
.map_err(anyhow::Error::from)
.with_context(|| "Failed to connect to Postgres.")?;
.expect("Failed to connect to Postgres.");
// Here we choose to bind explicitly to localhost, 127.0.0.1, for security
// reasons. This binding may cause issues in some environments. For example,

View file

@ -19,7 +19,6 @@ tokio = "0.2.22"
serde = "1.0.115"
config = { version = "0.10.1", default-features = false, features = ["yaml"] }
sqlx = { version = "0.4.0-beta.1", default-features = false, features = [ "runtime-tokio", "macros", "postgres", "uuid", "chrono", "migrate"] }
anyhow = "1.0.32"
uuid = { version = "0.8.1", features = ["v4"] }
chrono = "0.4.15"
tracing = "0.1.19"

View file

@ -1,4 +1,3 @@
use anyhow::Context;
use chapter04::configuration::get_configuration;
use chapter04::startup::run;
use chapter04::telemetry::{get_subscriber, init_subscriber};
@ -6,15 +5,14 @@ use sqlx::postgres::PgPool;
use std::net::TcpListener;
#[actix_rt::main]
async fn main() -> Result<(), anyhow::Error> {
async fn main() -> std::io::Result<()> {
let subscriber = get_subscriber("zero2prod".into(), "info".into());
init_subscriber(subscriber);
let configuration = get_configuration().expect("Failed to read configuration.");
let connection_pool = PgPool::connect(&configuration.database.connection_string())
.await
.map_err(anyhow::Error::from)
.with_context(|| "Failed to connect to Postgres.")?;
.expect("Failed to connect to Postgres.");
// Here we choose to bind explicitly to localhost, 127.0.0.1, for security
// reasons. This binding may cause issues in some environments. For example,