fc::Exception objects represent a C++ exception and usually includes stack traces and optional parameters to describe the internal state of FC++ at the time the exception happened. More...
#include <FCException.hpp>
Public Member Functions | |
virtual | ~Exception () FC_NOEXCEPT |
Destructor. More... | |
Exception (FC_WHERE_DEF, const boost::system::error_code &ec, const std::string &description, const fc::StrMap &m=fc::emptyMap()) | |
Constructor with a boost::system::error_code value. More... | |
Exception (FC_WHERE_DEF, const std::string &description, const fc::StrMap &m=fc::emptyMap()) | |
Constructor with a simple text message. More... | |
Exception (FC_WHERE_DEF, const fc::FtpServerReplyCodes code, const std::string &reply, const std::string &description, const fc::StrMap &m=fc::emptyMap()) | |
Constructor with a FTP server reply. These objects are usually constructed when the FTP server response is unexpected. More... | |
virtual const char * | what () const FC_NOEXCEPT |
Inherited from std::exception to provide a very simple 1-line text string. More... | |
virtual | operator std::string () const |
Convert the exception to a very detailed multi-line text block. More... | |
virtual std::string | to_string () const |
Convert the exception to a very detailed multi-line text block. More... | |
virtual void | display (const bool showDisplayStack=true) const |
Display the exception using std::cout . Calls to_string() to format the message. More... | |
Static Public Member Functions | |
static std::string | getLogFilename () |
Get the name of the file used to record FC++ exceptions. More... | |
static bool | createLogFile (const bool truncateNow=false) |
Create the fc_exception.log file used to record exceptions in FC++. More... | |
static bool | truncateLogFile () |
Alias for fc::Exception::createLogFile() to re-create the log file in which FC++ exceptions are logged. More... | |
static bool | removeLogFile () |
Remove the fc_exception.log file. More... | |
Public Attributes | |
int | othererror |
on Windows, this is set to WSAGetLastError() More... | |
int | olderrno |
errno at the time the exception was created More... | |
int | oldherrno |
of limited use; not typically shown More... | |
fc::FtpServerReplyCodes | ftpReplyCode |
FTP server reply code. More... | |
std::string | ftpReplyText |
FTP server raw text reply. More... | |
int | lineNumber |
source file line number More... | |
std::string | filename |
source file More... | |
std::string | function |
source function More... | |
std::string | text |
1-line exception text More... | |
std::chrono::high_resolution_clock::time_point | timestamp |
time when the exception was created More... | |
fc::StrVec | callstack |
call stack where the exception was created More... | |
fc::StrMap | map |
additional/optional debug information More... | |
boost::system::error_code | errorCode |
typically set by boost::asio More... | |
Protected Member Functions | |
virtual Exception & | init (FC_WHERE_DEF, const fc::FtpServerReplyCodes code, const std::string &reply, const std::string &description, const fc::StrMap &map) |
Initialize the exception, including getting the call stack where the exception was generated. More... | |
fc::Exception objects represent a C++ exception and usually includes stack traces and optional parameters to describe the internal state of FC++ at the time the exception happened.
These exceptions can be thrown from anywhere in the fc::... namespace.
|
virtual |
Destructor.
fc::Exception::Exception | ( | FC_WHERE_DEF | , |
const boost::system::error_code & | ec, | ||
const std::string & | description, | ||
const fc::StrMap & | m = fc::emptyMap() |
||
) |
Constructor with a boost::system::error_code value.
These objects are usually constructed due to a Boost API returning an error, such as boost::asio.
References FC_WHERE_PASS, init(), and fc::kInvalid.
fc::Exception::Exception | ( | FC_WHERE_DEF | , |
const std::string & | description, | ||
const fc::StrMap & | m = fc::emptyMap() |
||
) |
Constructor with a simple text message.
References FC_WHERE_PASS, init(), and fc::kInvalid.
fc::Exception::Exception | ( | FC_WHERE_DEF | , |
const fc::FtpServerReplyCodes | code, | ||
const std::string & | reply, | ||
const std::string & | description, | ||
const fc::StrMap & | m = fc::emptyMap() |
||
) |
Constructor with a FTP server reply. These objects are usually constructed when the FTP server response is unexpected.
References FC_WHERE_PASS, and init().
|
inlinevirtual |
Inherited from std::exception to provide a very simple 1-line text string.
Example output:
To get a more detailed multi-line error message, call to_string().
References text.
|
virtual |
Convert the exception to a very detailed multi-line text block.
This is the same as calling to_string().
Example output:
References fc::formatTimestamp2().
|
inlinevirtual |
Convert the exception to a very detailed multi-line text block.
Alias for operator std::string().
|
virtual |
Display the exception using std::cout
. Calls to_string() to format the message.
[in] | showDisplayStack | The call stack where the exception was created is always shown, but the call stack where fc::Exception::display() is being called from will only be shown if showDisplayStack is set to true . |
|
static |
Get the name of the file used to record FC++ exceptions.
This can change depending on fc::Options::setLogFileOutputDir(). If this file doesn't exist, then exceptions thrown by FC++ are not recorded. If this file exists, then any exception created by the FC++ library will be appended to this text file.
References FC_EXCEPTION_FILENAME, fc::Name::full(), fc::Options::getLogFileOutputDir(), and fc::Name::isRelative().
|
static |
Create the fc_exception.log
file used to record exceptions in FC++.
If this file exists, then any exception created by the FC++ library will be recorded in this file. The fc_exception.log
file can be manually created, but on some embedded systems (such as phones) it can be difficult to determine the exact path that will be used to run an application. The method createLogFile() was created specifically for those instances when it is difficult or impossible to determine beforehand the directory structure.
[in] | truncateNow | By default, the FC_EXCEPTION_FILENAME log file is appended when an exception is logged. This can cause the file to grow over time. If truncateNow is set to true , then the existing FC_EXCEPTION_FILENAME log file will be immediately truncated. All previous exceptions will be removed. |
TRUE
if the fc_exception.log
file is OK. FALSE
if the fc_exception.log
file cannot be created. E.g., read-only filesystem, or permission issues.References fc::SummaryLog::getLogFilename(), fc::libfcBitSize(), and fc::libfcVersionStr().
|
inlinestatic |
Alias for fc::Exception::createLogFile() to re-create the log file in which FC++ exceptions are logged.
References createLogFile().
|
static |
Remove the fc_exception.log
file.
TRUE
if the file was removed, or if it didn't exist. FALSE
if the file cannot be removed. E.g., read-only filesystem, or permission issues.References fc::SummaryLog::getLogFilename().
|
protectedvirtual |
Initialize the exception, including getting the call stack where the exception was generated.
This protected method is automatically called from the fc::Exception
constructors.
fc_exception.log
in the application's current working directory or the directory specified in fc::Options::setLogFileOutputDir(), the FC++ library will append information on any C++ exceptions thrown. References fc::SummaryLog::add(), and fc::SummaryLog::getLogFilename().
int fc::Exception::othererror |
on Windows, this is set to WSAGetLastError()
int fc::Exception::olderrno |
errno
at the time the exception was created
int fc::Exception::oldherrno |
of limited use; not typically shown
fc::FtpServerReplyCodes fc::Exception::ftpReplyCode |
FTP server reply code.
std::string fc::Exception::ftpReplyText |
FTP server raw text reply.
int fc::Exception::lineNumber |
source file line number
std::string fc::Exception::filename |
source file
std::string fc::Exception::function |
source function
std::string fc::Exception::text |
1-line exception text
std::chrono::high_resolution_clock::time_point fc::Exception::timestamp |
time when the exception was created
fc::StrVec fc::Exception::callstack |
call stack where the exception was created
fc::StrMap fc::Exception::map |
additional/optional debug information
boost::system::error_code fc::Exception::errorCode |
typically set by boost::asio