ExtJsFormatter: use ParameterError to correctly compute 'errors'
By default, 'errors' is now empty. Depend on proxmox 0.13.5.
This commit is contained in:
parent
53daae8e89
commit
99940358e3
@ -94,7 +94,7 @@ zstd = { version = "0.6", features = [ "bindgen" ] }
|
||||
pathpatterns = "0.1.2"
|
||||
pxar = { version = "0.10.1", features = [ "tokio-io" ] }
|
||||
|
||||
proxmox = { version = "0.13.4", features = [ "sortable-macro", "api-macro", "cli", "router", "tfa" ] }
|
||||
proxmox = { version = "0.13.5", features = [ "sortable-macro", "api-macro", "cli", "router", "tfa" ] }
|
||||
proxmox-acme-rs = "0.2.1"
|
||||
proxmox-apt = "0.7.0"
|
||||
proxmox-http = { version = "0.4.0", features = [ "client", "http-helpers", "websocket" ] }
|
||||
|
@ -14,7 +14,7 @@ openssl = "0.10"
|
||||
regex = "1.2"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
||||
proxmox = { version = "0.13.4", default-features = false, features = [ "api-macro" ] }
|
||||
proxmox = { version = "0.13.5", default-features = false, features = [ "api-macro" ] }
|
||||
|
||||
proxmox-systemd = { path = "../proxmox-systemd" }
|
||||
pbs-tools = { path = "../pbs-tools" }
|
||||
|
@ -28,7 +28,7 @@ tower-service = "0.3.0"
|
||||
xdg = "2.2"
|
||||
|
||||
pathpatterns = "0.1.2"
|
||||
proxmox = { version = "0.13.4", default-features = false, features = [ "cli" ] }
|
||||
proxmox = { version = "0.13.5", default-features = false, features = [ "cli" ] }
|
||||
proxmox-fuse = "0.1.1"
|
||||
proxmox-http = { version = "0.4.0", features = [ "client", "http-helpers", "websocket" ] }
|
||||
pxar = { version = "0.10.1", features = [ "tokio-io" ] }
|
||||
|
@ -16,7 +16,7 @@ nix = "0.19.1"
|
||||
regex = "1.2"
|
||||
once_cell = "1.3.1"
|
||||
|
||||
proxmox = { version = "0.13.4", default-features = false, features = [ "cli" ] }
|
||||
proxmox = { version = "0.13.5", default-features = false, features = [ "cli" ] }
|
||||
|
||||
pbs-api-types = { path = "../pbs-api-types" }
|
||||
pbs-buildcfg = { path = "../pbs-buildcfg" }
|
||||
|
@ -25,7 +25,7 @@ zstd = { version = "0.6", features = [ "bindgen" ] }
|
||||
pathpatterns = "0.1.2"
|
||||
pxar = "0.10.1"
|
||||
|
||||
proxmox = { version = "0.13.4", default-features = false, features = [ "api-macro" ] }
|
||||
proxmox = { version = "0.13.5", default-features = false, features = [ "api-macro" ] }
|
||||
|
||||
pbs-api-types = { path = "../pbs-api-types" }
|
||||
pbs-tools = { path = "../pbs-tools" }
|
||||
|
@ -14,7 +14,7 @@ nix = "0.19.1"
|
||||
regex = "1.2"
|
||||
tokio = { version = "1.6", features = [] }
|
||||
|
||||
proxmox = "0.13.4"
|
||||
proxmox = "0.13.5"
|
||||
proxmox-fuse = "0.1.1"
|
||||
|
||||
pbs-tools = { path = "../pbs-tools" }
|
||||
|
@ -18,7 +18,7 @@ bitflags = "1.2.1"
|
||||
regex = "1.2"
|
||||
udev = ">= 0.3, <0.5"
|
||||
|
||||
proxmox = { version = "0.13.4", default-features = false, features = [] }
|
||||
proxmox = { version = "0.13.5", default-features = false, features = [] }
|
||||
|
||||
pbs-api-types = { path = "../pbs-api-types" }
|
||||
pbs-tools = { path = "../pbs-tools" }
|
||||
|
@ -31,7 +31,7 @@ url = "2.1"
|
||||
walkdir = "2"
|
||||
zstd = { version = "0.6", features = [ "bindgen" ] }
|
||||
|
||||
proxmox = { version = "0.13.4", default-features = false, features = [ "tokio" ] }
|
||||
proxmox = { version = "0.13.5", default-features = false, features = [ "tokio" ] }
|
||||
|
||||
pbs-buildcfg = { path = "../pbs-buildcfg" }
|
||||
pbs-runtime = { path = "../pbs-runtime" }
|
||||
|
@ -22,7 +22,7 @@ zstd = { version = "0.6", features = [ "bindgen" ] }
|
||||
pathpatterns = "0.1.2"
|
||||
pxar = { version = "0.10.1", features = [ "tokio-io" ] }
|
||||
|
||||
proxmox = { version = "0.13.4", features = [ "sortable-macro", "api-macro", "cli", "router" ] }
|
||||
proxmox = { version = "0.13.5", features = [ "sortable-macro", "api-macro", "cli", "router" ] }
|
||||
|
||||
pbs-api-types = { path = "../pbs-api-types" }
|
||||
pbs-buildcfg = { path = "../pbs-buildcfg" }
|
||||
|
@ -16,7 +16,7 @@ tokio = { version = "1.6", features = [ "io-std", "rt", "rt-multi-thread", "time
|
||||
|
||||
pxar = { version = "0.10.1", features = [ "tokio-io" ] }
|
||||
|
||||
proxmox = { version = "0.13.4", features = [ "api-macro", "cli" ] }
|
||||
proxmox = { version = "0.13.5", features = [ "api-macro", "cli" ] }
|
||||
|
||||
pbs-api-types = { path = "../pbs-api-types" }
|
||||
pbs-buildcfg = { path = "../pbs-buildcfg" }
|
||||
|
@ -25,7 +25,7 @@ tokio-openssl = "0.6.1"
|
||||
tower-service = "0.3.0"
|
||||
url = "2.1"
|
||||
|
||||
proxmox = { version = "0.13.4", features = [ "router"] }
|
||||
proxmox = { version = "0.13.5", features = [ "router"] }
|
||||
|
||||
# fixme: remove this dependency (pbs_tools::broadcast_future)
|
||||
pbs-tools = { path = "../pbs-tools" }
|
||||
|
@ -6,7 +6,7 @@ use serde_json::{json, Value};
|
||||
use hyper::{Body, Response, StatusCode};
|
||||
use hyper::header;
|
||||
|
||||
use proxmox::api::{HttpError, RpcEnvironment};
|
||||
use proxmox::api::{HttpError, schema::ParameterError, RpcEnvironment};
|
||||
|
||||
/// Extension to set error message for server side logging
|
||||
pub(crate) struct ErrorMessageExtension(pub String);
|
||||
@ -61,6 +61,12 @@ struct JsonFormatter();
|
||||
|
||||
/// Format data as ``application/json``
|
||||
///
|
||||
/// The returned json object contains the following properties:
|
||||
///
|
||||
/// * ``data``: The result data (on success)
|
||||
///
|
||||
/// Any result attributes set on ``rpcenv`` are also added to the object.
|
||||
///
|
||||
/// Errors generates a BAD_REQUEST containing the error
|
||||
/// message as string.
|
||||
pub static JSON_FORMATTER: &'static dyn OutputFormatter = &JsonFormatter();
|
||||
@ -136,10 +142,18 @@ impl OutputFormatter for ExtJsFormatter {
|
||||
|
||||
fn format_error(&self, err: Error) -> Response<Body> {
|
||||
|
||||
let mut errors = vec![];
|
||||
let message: String;
|
||||
let errors;
|
||||
|
||||
let message = err.to_string();
|
||||
errors.push(&message);
|
||||
if let Some(param_err) = err.downcast_ref::<ParameterError>() {
|
||||
errors = param_err.errors().iter()
|
||||
.map(|(name, err)| format!("parameter '{}': {}", name, err))
|
||||
.collect();
|
||||
message = String::from("parameter verification errors");
|
||||
} else {
|
||||
errors = vec![];
|
||||
message = err.to_string();
|
||||
}
|
||||
|
||||
let result = json!({
|
||||
"message": message,
|
||||
|
@ -26,7 +26,7 @@ tokio-util = { version = "0.6", features = [ "codec", "io" ] }
|
||||
pathpatterns = "0.1.2"
|
||||
pxar = { version = "0.10.1", features = [ "tokio-io" ] }
|
||||
|
||||
proxmox = { version = "0.13.4", features = [ "router", "sortable-macro" ] }
|
||||
proxmox = { version = "0.13.5", features = [ "router", "sortable-macro" ] }
|
||||
|
||||
pbs-api-types = { path = "../pbs-api-types" }
|
||||
pbs-runtime = { path = "../pbs-runtime" }
|
||||
|
@ -11,6 +11,6 @@ bitflags = "1.2.1"
|
||||
lazy_static = "1.4"
|
||||
nom = "5.1"
|
||||
|
||||
proxmox = { version = "0.13.4", default-features = false }
|
||||
proxmox = { version = "0.13.5", default-features = false }
|
||||
|
||||
#pbs-tools = { path = "../pbs-tools" }
|
||||
|
@ -16,7 +16,7 @@ serde_json = "1.0"
|
||||
tokio = { version = "1.6", features = [ "rt", "rt-multi-thread" ] }
|
||||
|
||||
pathpatterns = "0.1.2"
|
||||
proxmox = { version = "0.13.4", default-features = false, features = [] }
|
||||
proxmox = { version = "0.13.5", default-features = false, features = [] }
|
||||
pxar = { version = "0.10.1", features = [ "tokio-io" ] }
|
||||
|
||||
pbs-client = { path = "../pbs-client" }
|
||||
|
Loading…
Reference in New Issue
Block a user