From 82c5884fdc7620cd4b0828a89fa8402cac024b18 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Wed, 12 Jun 2024 17:22:58 +0200 Subject: [PATCH] radicle: Improve SQL type errors --- radicle/src/sql.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/radicle/src/sql.rs b/radicle/src/sql.rs index 69ab4be0..f6dada6c 100644 --- a/radicle/src/sql.rs +++ b/radicle/src/sql.rs @@ -39,7 +39,7 @@ impl TryFrom<&Value> for RepoId { }), _ => Err(sql::Error { code: None, - message: Some("sql: invalid type for id".to_owned()), + message: Some(format!("sql: invalid type `{:?}` for id", value.kind())), }), } } @@ -65,7 +65,10 @@ impl TryFrom<&Value> for node::Features { Value::Integer(bits) => Ok(node::Features::from(*bits as u64)), _ => Err(sql::Error { code: None, - message: Some("sql: invalid type for node features".to_owned()), + message: Some(format!( + "sql: invalid type `{:?}` for node features", + value.kind() + )), }), } } @@ -82,7 +85,10 @@ impl TryFrom<&sql::Value> for Address { }), _ => Err(sql::Error { code: None, - message: Some("sql: invalid type for address".to_owned()), + message: Some(format!( + "sql: invalid type `{:?}` for address", + value.kind() + )), }), } } @@ -105,7 +111,10 @@ impl TryFrom<&Value> for UserAgent { }), _ => Err(sql::Error { code: None, - message: Some("sql: invalid type for user-agent".to_owned()), + message: Some(format!( + "sql: invalid type `{:?}` for user-agent", + value.kind() + )), }), } }