radicle: Improve SQL type errors

This commit is contained in:
cloudhead 2024-06-12 17:22:58 +02:00
parent a89a300390
commit 82c5884fdc
No known key found for this signature in database
1 changed files with 13 additions and 4 deletions

View File

@ -39,7 +39,7 @@ impl TryFrom<&Value> for RepoId {
}), }),
_ => Err(sql::Error { _ => Err(sql::Error {
code: None, 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)), Value::Integer(bits) => Ok(node::Features::from(*bits as u64)),
_ => Err(sql::Error { _ => Err(sql::Error {
code: None, 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 { _ => Err(sql::Error {
code: None, 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 { _ => Err(sql::Error {
code: None, code: None,
message: Some("sql: invalid type for user-agent".to_owned()), message: Some(format!(
"sql: invalid type `{:?}` for user-agent",
value.kind()
)),
}), }),
} }
} }