#ifndef __Exception_h__ #define __Exception_h__ #include #include #include #include namespace coreutils { /// /// Use an Exception oject whenever you want to throw an error for an exception condition /// to your calling stack to inform the program of the condition. /// class Exception { public: /// /// file/line default to the caller's actual location. std::source_location::current() /// is specifically defined by the standard to evaluate at the call site when used as a /// default argument - unlike __FILE__/__LINE__ (preprocessor macros, which were used /// here previously and always expanded to this header's own declaration line instead /// of the real throw site, since macro expansion happens before the compiler even sees /// "default argument" as a concept). Explicit callers (e.g. throw Exception(msg, /// __FILE__, __LINE__)) are unaffected - the signature is unchanged. /// Exception(std::string text, std::string file = std::source_location::current().file_name(), int line = std::source_location::current().line(), int errorNumber = errno); std::string className; std::string file; int line; std::string text; int errorNumber; }; } #endif