async fn get<T>(&self, name: &str) -> Result<T>
where
T: FromStr,
+ T::Err: std::fmt::Display,
{
let v: String = sqlx::query_scalar("SELECT [value] FROM [Settings] WHERE [name] = $1")
.bind(name)
.fetch_one(&self.pool)
.await?;
- T::from_str(&v).map_err(|_| {
+ T::from_str(&v).map_err(|error| {
DBError::Other(format!(
- "Can't convert string value \"{}\" when reading setting {}",
- v, name
+ "Can't convert string value \"{}\" when reading setting {}. Original error: {}",
+ v, name, error
))
})
}
get(services::ron::calendar::get_scheduled_recipes),
)
.route(
- "/calendar/schedule_recipe",
- post(services::ron::calendar::schedule_recipe)
+ "/calendar/scheduled_recipe",
+ post(services::ron::calendar::add_scheduled_recipe)
.delete(services::ron::calendar::rm_scheduled_recipe),
)
.route("/shopping_list", get(services::ron::shopping_list::get))
}
#[debug_handler]
-pub async fn schedule_recipe(
+pub async fn add_scheduled_recipe(
State(connection): State<db::Connection>,
Extension(context): Extension<Context>,
ExtractRon(ron): ExtractRon<common::ron_api::ScheduleRecipe>,
Ok(ScheduleRecipeResult::Ok)
} else {
request::post::<ron_api::ScheduleRecipeResult, _>(
- "calendar/schedule_recipe",
+ "calendar/scheduled_recipe",
ron_api::ScheduleRecipe {
recipe_id,
date,