// GNU Lesser General Public License v3.0 // Copyright (c) 2023 Bart Beumer // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License v3.0 as published by // the Free Software Foundation. // #include "bmrshared/ToTupleException.hpp" #include #include #include #include #include namespace bmrshared { ToTupleException::ToTupleException(std::vector keysMissing, std::vector keysNotUsed, std::vector paramErrors) : m_keysMissing(std::move(keysMissing)) , m_keysNotUsed(std::move(keysNotUsed)) , m_paramErrors(std::move(paramErrors)) , m_what(GenerateWhat(m_keysMissing, m_keysNotUsed, m_paramErrors)) { } ToTupleException::~ToTupleException() = default; const std::vector& ToTupleException::GetKeysMissing() const { return m_keysMissing; } const std::vector& ToTupleException::GetKeysNotUsed() const { return m_keysNotUsed; } const char* ToTupleException::what() const noexcept { return m_what.c_str(); } std::string ToTupleException::GenerateWhat(const std::vector& keysMissing, const std::vector& keysNotUsed, const std::vector& paramErrors) { std::stringstream ss; ss << "Errors while converting to tuple."; for (const auto& key : keysMissing) { ss << "\n - missing: " << key; } for (const auto& key : keysNotUsed) { ss << "\n - unused: " << key; } for (const auto& error : paramErrors) { ss << "\n - error: " << error.name << " \"" << error.type << "\""; } return ss.str(); } } // namespace bmrshared