mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
move config loading to config module
This separates concerns a bit more. We will probably want to extend the logic for config loading in the future, and that stuff should all live in the relevant place. This change points us in the right direction.
This commit is contained in:
parent
2b0bc140cf
commit
6b819d6f2d
3 changed files with 40 additions and 13 deletions
22
src/error.rs
22
src/error.rs
|
|
@ -1,6 +1,6 @@
|
|||
//! Error handling facilities
|
||||
|
||||
use std::{fmt, iter};
|
||||
use std::{fmt, iter, path::PathBuf};
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
|
|
@ -38,11 +38,8 @@ impl fmt::Display for DisplayWithSources<'_> {
|
|||
#[allow(missing_docs)]
|
||||
#[derive(Error, Debug)]
|
||||
pub(crate) enum Main {
|
||||
#[error("failed to read configuration file")]
|
||||
ConfigRead(#[source] std::io::Error),
|
||||
|
||||
#[error("failed to parse configuration")]
|
||||
ConfigParse(#[from] toml::de::Error),
|
||||
#[error("failed to load configuration")]
|
||||
Config(#[from] Config),
|
||||
|
||||
#[error("failed to initialize observability")]
|
||||
Observability(#[from] Observability),
|
||||
|
|
@ -74,3 +71,16 @@ pub(crate) enum Observability {
|
|||
#[error("tracing_flame error")]
|
||||
TracingFlame(#[from] tracing_flame::Error),
|
||||
}
|
||||
|
||||
/// Configuration errors
|
||||
// Missing docs are allowed here since that kind of information should be
|
||||
// encoded in the error messages themselves anyway.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Error, Debug)]
|
||||
pub(crate) enum Config {
|
||||
#[error("failed to read configuration file {1:?}")]
|
||||
Read(#[source] std::io::Error, PathBuf),
|
||||
|
||||
#[error("failed to parse configuration file {1:?}")]
|
||||
Parse(#[source] toml::de::Error, PathBuf),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue