This commit is contained in:
Valery Antopol 2022-02-24 01:02:46 +03:00
parent d9d77b91d9
commit 8a25cc65e4
3 changed files with 24 additions and 35 deletions

View File

@ -53,9 +53,9 @@ fn json_map_to_ivalues<'a, 'b>(
let mut iargs = Vec::new();
for (arg_name, arg_type) in arg_types {
let json_value = json_map.remove(arg_name).ok_or_else(|| {
De(format!("missing argument with name {}", arg_name))
})?;
let json_value = json_map
.remove(arg_name)
.ok_or_else(|| De(format!("missing argument with name {}", arg_name)))?;
let iarg = jvalue_to_ivalue(json_value, arg_type, record_types)?;
iargs.push(iarg);
}
@ -173,10 +173,7 @@ fn jvalue_to_ivalue(jvalue: JValue, ty: &IType, record_types: &MRecordTypes) ->
Ok(iargs)
}
_ => Err(De(format!(
"expected bytearray, got {:?}",
jvalue
))),
_ => Err(De(format!("expected bytearray, got {:?}", jvalue))),
}?;
Ok(IValue::Array(value))

View File

@ -104,20 +104,16 @@ impl From<std::convert::Infallible> for FaaSError {
macro_rules! json_to_faas_err {
($json_expr:expr, $module_name:expr, $function_name:expr) => {
$json_expr.map_err(|e| match e {
it_json_serde::ITJsonSeDeError::Se(_) => {
FaaSError::JsonOutputSerializationError {
it_json_serde::ITJsonSeDeError::Se(_) => FaaSError::JsonOutputSerializationError {
module_name: $module_name,
function_name: $function_name,
error: e,
}
}
it_json_serde::ITJsonSeDeError::De(_) => {
FaaSError::JsonArgumentsDeserializationError {
},
it_json_serde::ITJsonSeDeError::De(_) => FaaSError::JsonArgumentsDeserializationError {
module_name: $module_name,
function_name: $function_name,
error: e,
}
}
},
})
};
}

View File

@ -75,20 +75,16 @@ impl From<std::convert::Infallible> for FaaSError {
macro_rules! json_to_faas_err {
($json_expr:expr, $module_name:expr, $function_name:expr) => {
$json_expr.map_err(|e| match e {
it_json_serde::ITJsonSeDeError::Se(_) => {
FaaSError::JsonOutputSerializationError {
it_json_serde::ITJsonSeDeError::Se(_) => FaaSError::JsonOutputSerializationError {
module_name: $module_name,
function_name: $function_name,
error: e,
}
}
it_json_serde::ITJsonSeDeError::De(_) => {
FaaSError::JsonArgumentsDeserializationError {
},
it_json_serde::ITJsonSeDeError::De(_) => FaaSError::JsonArgumentsDeserializationError {
module_name: $module_name,
function_name: $function_name,
error: e,
}
}
},
})
};
}