It can be achieved by using predefined macros : __ FILE__ and __ LINE__ as below.
try {
throw std::runtime_error(" File Name :" __FILE__ " with Line Number as " + std::to_string(__LINE__));
}
catch (const std::exception& e) {
std::cout << e.what() << std::endl;
}