49#ifndef PFC_UI_ERRORS_HPP
50#define PFC_UI_ERRORS_HPP
52#include <nlohmann/json.hpp>
122 const std::string &
example =
"") {
123 std::ostringstream
oss;
124 oss <<
"Invalid configuration: Field '" <<
field_name <<
"' ";
127 oss <<
"is missing.\n";
129 oss <<
"has invalid value.\n";
132 oss <<
" Description: " << description <<
"\n";
133 oss <<
" Expected: " << expected_type <<
"\n";
134 oss <<
" Got: " << actual_value <<
"\n";
136 if (!valid_options.empty()) {
137 oss <<
" Valid options: ";
138 for (
size_t i = 0; i < valid_options.size(); ++i) {
139 oss <<
"'" << valid_options[i] <<
"'";
140 if (i < valid_options.size() - 1) oss <<
", ";
145 if (!example.empty()) {
146 oss <<
" Example: " << example;
197 std::ostringstream
oss;
201 if (value.is_null()) {
202 oss <<
" (type: null)";
203 }
else if (value.is_boolean()) {
204 oss <<
" (type: boolean)";
205 }
else if (value.is_number_integer()) {
206 oss <<
" (type: integer)";
207 }
else if (value.is_number_float()) {
208 oss <<
" (type: float)";
209 }
else if (value.is_string()) {
210 oss <<
" (type: string)";
211 }
else if (value.is_array()) {
212 oss <<
" (type: array)";
213 }
else if (value.is_object()) {
214 oss <<
" (type: object)";
290 const std::string &
context =
"field modifier") {
293 std::ostringstream
oss;
295 oss <<
" Valid types:\n";
299 oss <<
" Check spelling and see documentation for details.";
std::string format_config_error(const std::string &field_name, const std::string &description, const std::string &expected_type, const std::string &actual_value, const std::vector< std::string > &valid_options={}, const std::string &example="")
Format a helpful configuration error message.
Definition errors.hpp:118
std::vector< std::string > list_valid_field_modifiers()
List all registered field modifiers.
std::string get_json_value_string(const nlohmann::json &j, const std::string &field_name)
Get JSON value as string for error messages.
Definition errors.hpp:190
std::string format_unknown_modifier_error(const std::string &invalid_type, const std::string &context="field modifier")
Format error for unknown field modifier type.
Definition errors.hpp:289
Represents the global simulation domain (the "world").
Definition world.hpp:91