improve config parse errors, fix nixosModules field for stations
All checks were successful
nix-build-publish / check (push) Successful in 7m6s
All checks were successful
nix-build-publish / check (push) Successful in 7m6s
This commit is contained in:
parent
ce71c0429a
commit
79de647d2a
@ -88,16 +88,16 @@ impl Default for Config {
|
||||
impl std::str::FromStr for Config {
|
||||
type Err = ConfigError;
|
||||
fn from_str(s: &str) -> Result<Self, ConfigError> {
|
||||
toml::from_str(s).map_err(|_| ConfigError::Parse)
|
||||
toml::from_str(s).map_err(ConfigError::Parse)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ConfigError {
|
||||
Parse,
|
||||
Parse(toml::de::Error),
|
||||
StringParse,
|
||||
Serialize,
|
||||
IO,
|
||||
Serialize(toml::ser::Error),
|
||||
IO(std::io::Error),
|
||||
}
|
||||
|
||||
impl std::error::Error for ConfigError {}
|
||||
@ -105,23 +105,23 @@ impl std::error::Error for ConfigError {}
|
||||
impl std::fmt::Display for ConfigError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Parse => write!(f, "Failed to parse Config from string"),
|
||||
Self::Parse(e) => write!(f, "Failed to parse Config from string: {}", e),
|
||||
Self::StringParse => write!(f, "Failed to parse environment variable"),
|
||||
Self::Serialize => write!(f, "Failed to serialize Config to TOML"),
|
||||
Self::IO => write!(f, "Failed to write a configuration file"),
|
||||
Self::Serialize(e) => write!(f, "Failed to serialize Config to TOML: {}", e),
|
||||
Self::IO(e) => write!(f, "Failed to read or write a configuration file: {}", e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<toml::ser::Error> for ConfigError {
|
||||
fn from(_: toml::ser::Error) -> Self {
|
||||
ConfigError::Serialize
|
||||
fn from(err: toml::ser::Error) -> Self {
|
||||
ConfigError::Serialize(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for ConfigError {
|
||||
fn from(_: std::io::Error) -> Self {
|
||||
ConfigError::IO
|
||||
fn from(err: std::io::Error) -> Self {
|
||||
ConfigError::IO(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@
|
||||
type = types.str;
|
||||
description = "Station name";
|
||||
};
|
||||
address = mkOption {
|
||||
host = mkOption {
|
||||
type = types.str;
|
||||
description = "MPD service address";
|
||||
};
|
||||
@ -339,7 +339,7 @@
|
||||
${toTOML {inherit (cfg) base server stations;}}
|
||||
'';
|
||||
in ''
|
||||
ln -sf ${configFile} ./config.toml
|
||||
ln -sf ${configFile} ${cfg.dataDir}/config.toml
|
||||
'';
|
||||
};
|
||||
};
|
||||
@ -367,7 +367,7 @@
|
||||
{
|
||||
id = "test";
|
||||
name = "Test";
|
||||
address = "127.0.0.1";
|
||||
host = "127.0.0.1";
|
||||
port = 8080;
|
||||
}
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user