mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-06 20:56:31 +00:00
Improve error message when request contains the wrong type of placeholder
This commit is contained in:
@ -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()
|
||||||
|
Reference in New Issue
Block a user