Skip to main content

lib_humus/templating/
loader_error.rs

1// SPDX-FileCopyrightText: 2026 Slatian <baschdel@disroot.org>
2//
3// SPDX-License-Identifier: AGPL-3.0-or-later
4
5use lib_humus_configuration::HumusConfigError;
6
7use std::path::PathBuf;
8
9use crate::templating::{HumusFormatIdentifier, manifest::TemplatesManifestProblem};
10
11/// Returned when a [TemplatingEngine][crate::templating::TemplatingEngine] fails to initalize.
12#[derive(Debug, thiserror::Error)]
13pub enum TemplatingEngineLoaderError {
14	/// An error occourred while loading the template configuration file.
15	#[error("Error with template extra configuration:\n{0}")]
16	ConfigurationError(#[source] HumusConfigError),
17	/// An error occurred while loading the template manifest file.
18	#[error("Error with templates manifest file:\n{0}")]
19	TemplatesManifestError(#[source] HumusConfigError),
20	/// One or more problems were found in the templates manifest file.
21	#[error("Problems found in templates manifest:\n{0:?}")]
22	TemplatesManifestProblems(Vec<TemplatesManifestProblem>),
23	/// No template directory at.
24	#[error("No template directory found at {path:?}.")]
25	TemplateDirectoryNotFound {
26		/// Where the template directory was expected
27		path: PathBuf,
28	},
29	/// There was an error reading the template directory
30	#[error("Error reading template directory at {path:?}")]
31	TemplateDirectoryIoError {
32		/// Path to the template directory
33		path: PathBuf,
34		/// The I/O error that occurred
35		#[source]
36		error: std::io::Error,
37	},
38	/// An error occourred while parsing the templates.
39	#[error("Error parsing templates for format {format:?} at {path:?}:\n{tera_error}")]
40	TemplateParseError {
41		/// Path to the template directory
42		path: PathBuf,
43		/// For which format the templates were loaded
44		format: HumusFormatIdentifier,
45		/// what went wrong
46		#[source]
47		tera_error: tera::Error,
48	},
49}