R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BException.cxx
Go to the documentation of this file.
1#include "R3BException.h"
2#include <filesystem>
3#include <fmt/color.h>
4#include <fmt/core.h>
5
6namespace fs = std::filesystem;
7
8namespace
9{
10
11 std::string Print_msg_with_loc(const std::string& err, const boost::source_location& loc)
12 {
13 auto filepath = fs::path{ loc.file_name() };
14 return fmt::format(fmt::emphasis::bold | fg(fmt::color::red),
15 "{}:{}:{}: {}",
16 filepath.filename().string(),
17 loc.line(),
18 loc.function_name(),
19 err);
20 }
21
22} // namespace
23namespace R3B
24{
25
26 runtime_error::runtime_error(const std::string& err, const boost::source_location& loc)
27 : std::runtime_error{ Print_msg_with_loc(err, loc) }
28 {
29 }
30
31 logic_error::logic_error(const std::string& err, const boost::source_location& loc)
32 : std::logic_error{ Print_msg_with_loc(err, loc) }
33 {
34 }
35} // namespace R3B
logic_error(const std::string &err, const boost::source_location &loc=BOOST_CURRENT_LOCATION)
runtime_error(const std::string &err, const boost::source_location &loc=BOOST_CURRENT_LOCATION)