mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-27 16:51:01 +00:00
Return docid in case of errors while rendering the document template
This commit is contained in:
@ -119,6 +119,7 @@ impl Prompt {
|
||||
'doc: 'a, // lifetime of the allocator, will live for an entire chunk of documents
|
||||
>(
|
||||
&self,
|
||||
external_docid: &str,
|
||||
document: impl crate::update::new::document::Document<'a> + Debug,
|
||||
field_id_map: &RefCell<GlobalFieldsIdsMap>,
|
||||
doc_alloc: &'doc Bump,
|
||||
@ -130,9 +131,12 @@ impl Prompt {
|
||||
self.max_bytes.unwrap_or_else(default_max_bytes).get(),
|
||||
doc_alloc,
|
||||
);
|
||||
self.template
|
||||
.render_to(&mut rendered, &context)
|
||||
.map_err(RenderPromptError::missing_context)?;
|
||||
self.template.render_to(&mut rendered, &context).map_err(|liquid_error| {
|
||||
RenderPromptError::missing_context_with_external_docid(
|
||||
external_docid.to_owned(),
|
||||
liquid_error,
|
||||
)
|
||||
})?;
|
||||
Ok(std::str::from_utf8(rendered.into_bump_slice())
|
||||
.expect("render can only write UTF-8 because all inputs and processing preserve utf-8"))
|
||||
}
|
||||
|
Reference in New Issue
Block a user