mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 06:44:27 +01:00
Update meilisearch-lib/src/document_formats.rs
Co-authored-by: Clément Renault <renault.cle@gmail.com>
This commit is contained in:
parent
13a0e78d3f
commit
b28aa8e666
@ -39,22 +39,15 @@ impl Display for DocumentFormatError {
|
||||
// https://github.com/meilisearch/meilisearch/issues/2107
|
||||
// The user input maybe insanely long. We need to truncate it.
|
||||
let mut serde_msg = se.to_string();
|
||||
let prefix = r#"invalid type: string ""#;
|
||||
if serde_msg.starts_with(prefix) {
|
||||
let start_idx = prefix.len();
|
||||
if let Some(end_idx) = serde_msg.rfind("\"") {
|
||||
if end_idx - start_idx > 100 {
|
||||
serde_msg.replace_range(start_idx + 50..end_idx - 50, " ... ");
|
||||
}
|
||||
} else {
|
||||
serde_msg = String::from("");
|
||||
}
|
||||
let ellipsis = "...";
|
||||
if serde_msg.len() > 100 + ellipsis.len() {
|
||||
serde_msg.replace_range(50..serde_msg.len() - 50, ellipsis);
|
||||
}
|
||||
|
||||
write!(
|
||||
f,
|
||||
"The `{}` payload provided is malformed. `Couldn't serialize document value: {}`.",
|
||||
b,serde_msg
|
||||
b, serde_msg
|
||||
)
|
||||
}
|
||||
_ => write!(f, "The `{}` payload provided is malformed: `{}`.", b, me),
|
||||
|
Loading…
Reference in New Issue
Block a user