CppCommon  1.0.4.1
C++ Common Library
fatal.cpp
Go to the documentation of this file.
1 
9 #include "errors/fatal.h"
10 
11 #include <cstdlib>
12 #include <iostream>
13 
14 namespace CppCommon {
15 
16 void fatal(const SourceLocation& location, const StackTrace& trace, const std::string& message, int error) noexcept
17 {
18  std::cerr << "Fatal error: " << message << std::endl;
19  std::cerr << "System error: " << error << std::endl;
20  std::cerr << "System message: " << SystemError::Description(error) << std::endl;
21  std::cerr << "Source location: " << location.string() << std::endl;
22  std::cerr << "Stack trace: " << std::endl << trace.string() << std::endl;
23  std::abort();
24 }
25 
26 void fatal(const SourceLocation& location, const StackTrace& trace, const std::exception& fatal) noexcept
27 {
28  std::cerr << fatal.what() << std::endl;
29  std::abort();
30 }
31 
32 } // namespace CppCommon
Stack trace snapshot provider.
Definition: stack_trace.h:33
static std::string Description()
Convert the last system error code to the system error description.
Definition: system_error.h:52
Fatal abort execution definition.
C++ Common project definitions.
Definition: token_bucket.h:15
void fatal(const SourceLocation &location, const StackTrace &trace, const std::string &message, int error=SystemError::GetLast()) noexcept
Fatal abort execution.
Definition: fatal.cpp:16