all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] rest-server: use hashmap for parameter errors
@ 2021-10-19 11:09 Dominik Csapak
  2021-10-21  4:32 ` [pbs-devel] applied: " Dietmar Maurer
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2021-10-19 11:09 UTC (permalink / raw)
  To: pbs-devel

our ui expects a map here with 'field: "error"'. This way it can mark
the relevant field as invalid and correctly shows the complete error
message

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 proxmox-rest-server/src/formatter.rs | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/proxmox-rest-server/src/formatter.rs b/proxmox-rest-server/src/formatter.rs
index 6d050997..cb5774d5 100644
--- a/proxmox-rest-server/src/formatter.rs
+++ b/proxmox-rest-server/src/formatter.rs
@@ -1,4 +1,5 @@
 //! Helpers to format response data
+use std::collections::HashMap;
 
 use anyhow::{Error};
 use serde_json::{json, Value};
@@ -144,15 +145,14 @@ impl  OutputFormatter for ExtJsFormatter {
     fn format_error(&self, err: Error) -> Response<Body> {
 
         let message: String;
-        let errors;
+        let mut errors = HashMap::new();
 
         if let Some(param_err) = err.downcast_ref::<ParameterError>() {
-            errors = param_err.errors().iter()
-                .map(|(name, err)| format!("parameter '{}': {}", name, err))
-                .collect();
+            for (name, err) in param_err.errors().iter() {
+                errors.insert(name, err.to_string());
+            }
             message = String::from("parameter verification errors");
         } else {
-            errors = vec![];
             message = err.to_string();
         }
 
-- 
2.30.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pbs-devel] applied: [PATCH proxmox-backup] rest-server: use hashmap for parameter errors
  2021-10-19 11:09 [pbs-devel] [PATCH proxmox-backup] rest-server: use hashmap for parameter errors Dominik Csapak
@ 2021-10-21  4:32 ` Dietmar Maurer
  0 siblings, 0 replies; 2+ messages in thread
From: Dietmar Maurer @ 2021-10-21  4:32 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

applied




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-21  4:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 11:09 [pbs-devel] [PATCH proxmox-backup] rest-server: use hashmap for parameter errors Dominik Csapak
2021-10-21  4:32 ` [pbs-devel] applied: " Dietmar Maurer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal