summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-11-06 13:25:27 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-11-06 13:28:35 +0100
commit16fc9a21748af695e2ea44e823bef1dc34996d3f (patch)
tree5e09dd7da73522ab40f8c2d387946f21d0a81301 /src/db
parent6605f88bd7b87dfb91dedf6d4f12eadd9a19e6c9 (diff)
Add logging output and error context messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/db')
-rw-r--r--src/db/models/submit.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/db/models/submit.rs b/src/db/models/submit.rs
index b8aed64..37f5189 100644
--- a/src/db/models/submit.rs
+++ b/src/db/models/submit.rs
@@ -1,6 +1,8 @@
use std::ops::Deref;
+use anyhow::anyhow;
use anyhow::Error;
+use anyhow::Context;
use anyhow::Result;
use diesel::PgConnection;
use diesel::prelude::*;
@@ -63,11 +65,13 @@ impl Submit {
diesel::insert_into(submits::table)
.values(&new_submit)
.on_conflict_do_nothing()
- .execute(database_connection)?;
+ .execute(database_connection)
+ .context("Inserting new submit into submits table")?;
dsl::submits
.filter(uuid.eq(uuid))
.first::<Submit>(database_connection)
+ .context("Loading submit")
.map_err(Error::from)
}
}