diff --git a/src/main.rs b/src/main.rs index 0f91af9..e56ecdf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1212,6 +1212,21 @@ fn main() -> std::io::Result<()> { .app_data::>>>(Data::new(Mutex::new(Box::new( preview_dao, )))) + .app_data( + web::JsonConfig::default() + .error_handler(|err, req| { + let detail = err.to_string(); + log::warn!( + "JSON parse error on {} {}: {}", + req.method(), + req.uri(), + detail + ); + let response = HttpResponse::BadRequest() + .json(serde_json::json!({"error": detail})); + actix_web::error::InternalError::from_response(err, response).into() + }), + ) .app_data::>(Data::new(app_data.insight_generator.clone())) .wrap(prometheus.clone()) })