Display validation errors

This commit is contained in:
eraden 2023-07-30 22:01:00 +02:00 committed by Adrian Woźniak
parent 0a85d78a9b
commit eb35037bca
3 changed files with 7 additions and 2 deletions

View File

@ -19,7 +19,7 @@ name = "actix_admin"
path = "src/lib.rs" path = "src/lib.rs"
[features] [features]
default = ["bulma_css"] default = ["bulma_css", 'enable-tracing']
bulma_css = [] bulma_css = []
enable-tracing = ['tracing'] enable-tracing = ['tracing']

View File

@ -118,7 +118,7 @@ pub enum ActixAdminError {
impl error::ResponseError for ActixAdminError { impl error::ResponseError for ActixAdminError {
fn error_response(&self) -> HttpResponse { fn error_response(&self) -> HttpResponse {
#[cfg(feature="enable-tracing")] #[cfg(feature="enable-tracing")]
tracing::debug!("{self}"); tracing::debug!("{self:#?}");
HttpResponse::build(self.status_code()) HttpResponse::build(self.status_code())
.insert_header(ContentType::html()) .insert_header(ContentType::html())
.body(self.to_string()) .body(self.to_string())

View File

@ -86,6 +86,11 @@ pub async fn create_or_edit_post<E: ActixAdminViewModelTrait>(
if model.has_errors() { if model.has_errors() {
errors.push(ActixAdminError::ValidationErrors); errors.push(ActixAdminError::ValidationErrors);
#[cfg(feature="enable-tracing")]
{
tracing::error!("OP errors: {errors:#?}");
tracing::debug!("Model errors: {:#?}", model.errors);
}
render_form::<E>( render_form::<E>(
req, req,
actix_admin, actix_admin,