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, const std::source_location& location) 11 : { 12 6 : std::ostringstream oss; 13 12 : oss << "Error: " << description << "\nLine: " << fs::path(location.file_name()).filename().string() << ":" 14 6 : << location.line() << "\nFunction: " << location.function_name(); 15 12 : return oss.str(); 16 6 : }