mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 12:27:13 +02:00
Improve error message when request contains the wrong type of placeholder
This commit is contained in:
parent
ede456c5b0
commit
f6287602e9
1 changed files with 18 additions and 9 deletions
|
@ -561,6 +561,7 @@ impl Request {
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
let message =
|
let message =
|
||||||
error.error_message("request", REQUEST_PLACEHOLDER, REPEAT_PLACEHOLDER);
|
error.error_message("request", REQUEST_PLACEHOLDER, REPEAT_PLACEHOLDER);
|
||||||
|
let message = format!("{message}\n - Note: this template is using a document template, and so expects to contain the placeholder {REQUEST_PLACEHOLDER:?} rather than {REQUEST_FRAGMENT_PLACEHOLDER:?}");
|
||||||
return Err(NewEmbedderError::rest_could_not_parse_template(message));
|
return Err(NewEmbedderError::rest_could_not_parse_template(message));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -592,15 +593,23 @@ impl RequestFromFragments {
|
||||||
request: Value,
|
request: Value,
|
||||||
search_fragments: impl IntoIterator<Item = (String, Value)>,
|
search_fragments: impl IntoIterator<Item = (String, Value)>,
|
||||||
) -> Result<Self, NewEmbedderError> {
|
) -> Result<Self, NewEmbedderError> {
|
||||||
let request =
|
let request = match InjectableValue::new(
|
||||||
match InjectableValue::new(request, REQUEST_FRAGMENT_PLACEHOLDER, REPEAT_PLACEHOLDER) {
|
request,
|
||||||
Ok(template) => template,
|
REQUEST_FRAGMENT_PLACEHOLDER,
|
||||||
Err(error) => {
|
REPEAT_PLACEHOLDER,
|
||||||
let message =
|
) {
|
||||||
error.error_message("request", REQUEST_PLACEHOLDER, REPEAT_PLACEHOLDER);
|
Ok(template) => template,
|
||||||
return Err(NewEmbedderError::rest_could_not_parse_template(message));
|
Err(error) => {
|
||||||
}
|
let message = error.error_message(
|
||||||
};
|
"request",
|
||||||
|
REQUEST_FRAGMENT_PLACEHOLDER,
|
||||||
|
REPEAT_PLACEHOLDER,
|
||||||
|
);
|
||||||
|
let message = format!("{message}\n - Note: this template is using fragments, and so expects to contain the placeholder {REQUEST_FRAGMENT_PLACEHOLDER:?} rathern than {REQUEST_PLACEHOLDER:?}");
|
||||||
|
|
||||||
|
return Err(NewEmbedderError::rest_could_not_parse_template(message));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let search_fragments: Result<_, NewEmbedderError> = search_fragments
|
let search_fragments: Result<_, NewEmbedderError> = search_fragments
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue