Update create_or_edit_post.rs

This commit is contained in:
Adrian Woźniak 2023-07-28 22:05:25 +02:00
parent 27b6889a8b
commit da466306e1

View File

@ -125,6 +125,8 @@ pub async fn create_or_edit_post<E: ActixAdminViewModelTrait>(
.finish()) .finish())
} }
Err(e) => { Err(e) => {
#[cfg(enable_tracing)]
tracing::error!("{e}");
errors.push(e); errors.push(e);
render_form::<E>( render_form::<E>(
req, req,
@ -184,13 +186,21 @@ async fn render_form<E: ActixAdminViewModelTrait>(
let notifications: Vec<ActixAdminNotification> = errors let notifications: Vec<ActixAdminNotification> = errors
.into_iter() .into_iter()
.map(|err| ActixAdminNotification::from(err)) .map(|err| {
#[cfg(enable_tracing)]
tracing::error!("{e}");
ActixAdminNotification::from(err)
})
.collect(); .collect();
ctx.insert("notifications", &notifications); ctx.insert("notifications", &notifications);
let body = actix_admin.tera let body = actix_admin.tera
.render("create_or_edit.html", &ctx) .render("create_or_edit.html", &ctx)
.map_err(|err| error::ErrorInternalServerError(err))?; .map_err(|err| {
#[cfg(enable_tracing)]
tracing::error!("{e}");
error::ErrorInternalServerError(err)
})?;
Ok(HttpResponse::Ok().content_type("text/html").body(body)) Ok(HttpResponse::Ok().content_type("text/html").body(body))
} }