Line data Source code
1 : #include "ExceptionWithLocation.hpp" 2 : 3 : #include <sstream> 4 : 5 6 : ExceptionWithLocation::ExceptionWithLocation(const std::string& description, const std::source_location location) 6 6 : : std::runtime_error(buildMessage(description, location)) 7 : { 8 6 : } 9 : 10 6 : std::string ExceptionWithLocation::buildMessage(const std::string& description, 11 : [[maybe_unused]] const std::source_location& location) 12 : { 13 6 : std::ostringstream oss; 14 6 : oss << "Error: " << description; 15 : 16 : #ifdef DEBUG 17 12 : oss << "\nLine: " << fs::path(location.file_name()).filename().string() << ":" << location.line() 18 6 : << "\nFunction: " << location.function_name(); 19 : #endif 20 : 21 12 : return oss.str(); 22 6 : }