On this page
article
peary/config/exceptions.hpp
peary/config/exceptions.hpp
Peary configuration exceptions. More…
Namespaces
| Name |
|---|
| peary |
| peary::config |
Classes
| Name | |
|---|---|
| class | peary::config::ConfigurationError Base class for configuration-related errors. |
| class | peary::config::InvalidSectionError Exception class for invalid configuration sections. |
| class | peary::config::MissingKeyError Exception class for missing configuration keys. |
| class | peary::config::InvalidKeyError Exception class for invalid configuration keys. |
| class | peary::config::InvalidTypeError Exception class for invalid configuration types. |
| class | peary::config::InvalidValueError Exception class for invalid configuration values. |
Detailed Description
Peary configuration exceptions.
Copyright: Copyright (c) 2016-2025 CERN and the Peary Caribou authors. This software is distributed under the terms of the LGPL-3.0-only License, copied verbatim in the file “LICENSE.md”. SPDX-License-Identifier: LGPL-3.0-only
Source code
#pragma once
#include <string_view>
#include "peary/utils/exceptions.hpp"
namespace peary::config {
class ConfigurationError : public utils::RuntimeError {};
class InvalidSectionError : public ConfigurationError {
public:
explicit InvalidSectionError(std::string_view section) {
_message = "Invalid section: ";
_message += section;
};
};
class MissingKeyError : public ConfigurationError {
public:
explicit MissingKeyError(std::string_view key, std::string_view section) {
_message = "Missing key: ";
_message += key;
_message += " in section: ";
_message += section;
}
};
class InvalidKeyError : public ConfigurationError {
public:
explicit InvalidKeyError(std::string_view key, std::string_view section, std::string_view reason = "") {
_message = "Invalid key: ";
_message += key;
_message += " in section: ";
_message += section;
if(!reason.empty()) {
_message += ": ";
_message += reason;
}
}
};
class InvalidTypeError : public ConfigurationError {
public:
explicit InvalidTypeError(std::string_view key,
std::string_view section,
std::string_view ktype,
std::string_view etype,
std::string_view reason = "") {
_message = "Invalid type for key ";
_message += key;
_message += " in section ";
_message += section;
_message += ": expected ";
_message += etype;
_message += ", got ";
_message += ktype;
if(!reason.empty()) {
_message += ": ";
_message += reason;
}
}
};
class InvalidValueError : public ConfigurationError {
public:
explicit InvalidValueError(std::string_view key,
std::string_view section,
std::string_view value,
std::string_view reason = "") {
_message = "Invalid value: ";
_message += value;
_message += " for key: ";
_message += key;
_message += " in section: ";
_message += section;
if(!reason.empty()) {
_message += ": ";
_message += reason;
}
}
};
} // namespace peary::config
Updated on 2025-11-14 at 11:31:23 +0100