mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 04:17:10 +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) => {
|
||||
let message =
|
||||
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));
|
||||
}
|
||||
};
|
||||
|
@ -592,15 +593,23 @@ impl RequestFromFragments {
|
|||
request: Value,
|
||||
search_fragments: impl IntoIterator<Item = (String, Value)>,
|
||||
) -> Result<Self, NewEmbedderError> {
|
||||
let request =
|
||||
match InjectableValue::new(request, REQUEST_FRAGMENT_PLACEHOLDER, REPEAT_PLACEHOLDER) {
|
||||
Ok(template) => template,
|
||||
Err(error) => {
|
||||
let message =
|
||||
error.error_message("request", REQUEST_PLACEHOLDER, REPEAT_PLACEHOLDER);
|
||||
return Err(NewEmbedderError::rest_could_not_parse_template(message));
|
||||
}
|
||||
};
|
||||
let request = match InjectableValue::new(
|
||||
request,
|
||||
REQUEST_FRAGMENT_PLACEHOLDER,
|
||||
REPEAT_PLACEHOLDER,
|
||||
) {
|
||||
Ok(template) => template,
|
||||
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
|
||||
.into_iter()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue