Clearmatics Libsnark  0.1
C++ library for zkSNARK proofs
Static Public Member Functions | List of all members
gadgetlib2::ErrorHandling Class Reference

#include <infrastructure.hpp>

Static Public Member Functions

static void __noreturn fatalError (const ::std::string &msg)
 
static void __noreturn fatalError (const std::stringstream &msg)
 
static void printStacktrace ()
 

Detailed Description

The ErrorHandling class containimplements the functionality of displaying the content of error messages (including content of call stack when error happened), and exiting the program.

Definition at line 77 of file infrastructure.hpp.

Member Function Documentation

◆ fatalError() [1/2]

void gadgetlib2::ErrorHandling::fatalError ( const ::std::string &  msg)
static

Definition at line 73 of file infrastructure.cpp.

74 {
75 #ifdef DEBUG
76  ::std::cerr << "ERROR: " << msg << ::std::endl << ::std::endl;
78  throw ::std::runtime_error(msg);
79 #else
80  libff::UNUSED(msg);
81  const ::std::string releaseMsg(
82  "Fatal error encountered. Run debug build for more"
83  " information and stack trace.");
84  ::std::cerr << "ERROR: " << releaseMsg << ::std::endl << ::std::endl;
85  throw ::std::runtime_error(releaseMsg);
86 #endif
87 }
Here is the call graph for this function:

◆ fatalError() [2/2]

static void __noreturn gadgetlib2::ErrorHandling::fatalError ( const std::stringstream &  msg)
static

◆ printStacktrace()

void gadgetlib2::ErrorHandling::printStacktrace ( )
static

Definition at line 94 of file infrastructure.cpp.

95 {
96 #ifdef __GLIBC__
97  std::cerr << "Stack trace (pipe through c++filt to demangle identifiers):"
98  << std::endl;
99  const int maxFrames = 100;
100  void *frames[maxFrames];
101  // Fill array with pointers to stack frames
102  int numFrames = backtrace(frames, maxFrames);
103  // Decode frames and print them to stderr
104  backtrace_symbols_fd(frames, numFrames, STDERR_FILENO);
105 #else
106  // TODO make this available for non-glibc platforms (e.g. musl libc on Linux
107  // and Windows)
108  std::cerr << " (stack trace not available on this platform)" << std::endl;
109 #endif // __GNUC__
110 }
Here is the caller graph for this function:

The documentation for this class was generated from the following files:
gadgetlib2::ErrorHandling::printStacktrace
static void printStacktrace()
Definition: infrastructure.cpp:94