From f48d404a15f57d49174a18d6149ccab181b3f99f Mon Sep 17 00:00:00 2001 From: asonix Date: Wed, 18 Mar 2020 17:37:22 -0500 Subject: [PATCH] Add logging for unhydrated values --- src/db.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/db.rs b/src/db.rs index 62a1118..eac926c 100644 --- a/src/db.rs +++ b/src/db.rs @@ -1,7 +1,7 @@ use activitystreams::primitives::XsdAnyUri; use anyhow::Error; use bb8_postgres::tokio_postgres::{row::Row, Client}; -use log::info; +use log::{info, warn}; use rsa::RSAPrivateKey; use rsa_pem::KeyExt; use std::collections::HashSet; @@ -148,15 +148,25 @@ pub async fn hydrate_listeners(client: &Client) -> Result, Er parse_rows(rows) } -fn parse_rows(rows: Vec) -> Result, Error> +fn parse_rows(rows: Vec) -> Result, Error> where - T: std::str::FromStr + Eq + std::hash::Hash, + T: std::str::FromStr + Eq + std::hash::Hash, + E: std::fmt::Display, { let hs = rows .into_iter() - .filter_map(move |row| { - let s: String = row.try_get(0).ok()?; - s.parse().ok() + .filter_map(move |row| match row.try_get::<_, String>(0) { + Ok(s) => match s.parse() { + Ok(t) => Some(t), + Err(e) => { + warn!("Couln't parse row, '{}', {}", s, e); + None + } + }, + Err(e) => { + warn!("Couldn't get column, {}", e); + None + } }) .collect();