Fix translation syntax errors panicking on hot reload

This commit is contained in:
Olivier 'reivilibre' 2023-03-03 23:31:24 +00:00
parent 6c6a129ddb
commit 6ca36aaa8e

View File

@ -23,6 +23,7 @@ pub use hornbeam_interpreter::Params;
use crate::interpreted::hot_reload::start_hot_reloader;
pub use lazy_static::lazy_static;
use tokio::io;
#[cfg(feature = "hot_reload")]
pub mod hot_reload;
@ -100,7 +101,11 @@ fn load_new_template_system(
translation_dir: &Path,
) -> Result<LoadedTemplates<FluentLocalisationSystem>, InterpreterError<Infallible, Infallible>> {
let localisation_system = FluentLocalisationSystem::new(translation_dir, default_locale)
.expect("Failed to create Fluent localisation system for Hornbeam environment");
.map_err(|err| {
InterpreterError::TemplateFindError(format!(
"Failed to create Fluent localisation system for Hornbeam environment: {err:?}"
))
})?;
let mut templates = LoadedTemplates::new(localisation_system);
templates.load_templates_from_dir(template_dir)?;
Ok(templates)