TrueReality  v0.1.1912
trUtil::Exception Class Reference

This is the exception class used throughout the engine. More...

#include <Exception.h>

Inheritance diagram for trUtil::Exception:

Public Member Functions

 Exception (const std::string &message, const std::string &filename, unsigned int linenum)
 Constructor - Initializes the exception and logs it. More...
 
virtual ~Exception ()
 Destructor. More...
 
const std::string & What () const
 The message to be displayed when this exception is thrown. More...
 
const std::string & File () const
 The filename associated with this exception. More...
 
unsigned int Line () const
 The line number associated with this exception. More...
 
std::string ToString () const
 Converts this exception to a string. More...
 
void Print () const
 Prints the exception to the console. More...
 
void LogException (trUtil::Logging::LogLevel level=trUtil::Logging::LogLevel::LOG_ERROR) const
 Logs the exception to the default logger. More...
 
void LogException (trUtil::Logging::LogLevel level, const std::string &loggerName) const
 Logs the exception to the following log level using the logger. More...
 
void LogException (trUtil::Logging::LogLevel level, trUtil::Logging::Log &logger) const
 Logs the exception to the following log level using the given logger. More...
 

Private Attributes

std::string mMessage
 
std::string mFileName
 
unsigned int mLineNum
 

Detailed Description

This is the exception class used throughout the engine.

Users should derive and create concrete instances.

Definition at line 48 of file Exception.h.

Constructor & Destructor Documentation

◆ Exception()

trUtil::Exception::Exception ( const std::string &  message,
const std::string &  filename,
unsigned int  linenum 
)

Constructor - Initializes the exception and logs it.

Parameters
message- Message to display about the exception.
filename- File the exception was thrown from.
linenum- Line number in the file from which the exception was thrown.

Definition at line 34 of file Exception.cpp.

References trUtil::Logging::Log::GetInstance(), LOG_DEBUG, and LogException().

Here is the call graph for this function:

◆ ~Exception()

trUtil::Exception::~Exception ( )
virtual

Destructor.

Definition at line 82 of file Exception.cpp.

Member Function Documentation

◆ File()

const std::string & trUtil::Exception::File ( ) const

The filename associated with this exception.

Returns
A reference to a const std::string.

Definition at line 94 of file Exception.cpp.

References mFileName.

◆ Line()

unsigned int trUtil::Exception::Line ( ) const

The line number associated with this exception.

Returns
An int.

Definition at line 100 of file Exception.cpp.

References mLineNum.

◆ LogException() [1/3]

void trUtil::Exception::LogException ( trUtil::Logging::LogLevel  level = trUtil::Logging::LogLevel::LOG_ERROR) const

Logs the exception to the default logger.

Parameters
level(Optional) The level/type of logging.

Definition at line 60 of file Exception.cpp.

References trUtil::Logging::Log::GetInstance().

Referenced by trUtil::PathUtils::CreateDataPathTree(), trUtil::PathUtils::CreateDataPathTrees(), trUtil::PathUtils::CreateUserDataPathTree(), trUtil::FileUtils::DirDelete(), Exception(), trUtil::VersionUtil::GetCurrentCommitNum(), LogException(), main(), trUtil::JSON::File::ReadFromFile(), and trUtil::JSON::File::WriteToFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogException() [2/3]

void trUtil::Exception::LogException ( trUtil::Logging::LogLevel  level,
const std::string &  loggerName 
) const

Logs the exception to the following log level using the logger.

Parameters
levelThe level/type of logging.
loggerNamethe name passed to "getInstance" of the Logger.

Definition at line 66 of file Exception.cpp.

References trUtil::Logging::Log::GetInstance(), and LogException().

Here is the call graph for this function:

◆ LogException() [3/3]

void trUtil::Exception::LogException ( trUtil::Logging::LogLevel  level,
trUtil::Logging::Log logger 
) const

Logs the exception to the following log level using the given logger.

Parameters
levelThe level/type of logging.
[in,out]loggerthe actual log instance used to log.

Definition at line 72 of file Exception.cpp.

References trUtil::Logging::Log::IsLevelEnabled(), trUtil::Logging::Log::LogMessage(), mFileName, mLineNum, and mMessage.

Here is the call graph for this function:

◆ Print()

void trUtil::Exception::Print ( ) const

Prints the exception to the console.

Definition at line 44 of file Exception.cpp.

References mFileName, mLineNum, and mMessage.

◆ ToString()

std::string trUtil::Exception::ToString ( ) const

Converts this exception to a string.

The string contains the reason, line number and file the exception was thrown from.

Returns
The string version of this exception.

Definition at line 52 of file Exception.cpp.

References mFileName, mLineNum, and mMessage.

Referenced by trUtil::DirectoryPush::DirectoryPush(), main(), and trUtil::operator<<().

Here is the caller graph for this function:

◆ What()

const std::string & trUtil::Exception::What ( ) const

The message to be displayed when this exception is thrown.

Returns
A reference to a const std::string.

Definition at line 88 of file Exception.cpp.

References mMessage.

Member Data Documentation

◆ mFileName

std::string trUtil::Exception::mFileName
private

Definition at line 144 of file Exception.h.

Referenced by File(), LogException(), Print(), and ToString().

◆ mLineNum

unsigned int trUtil::Exception::mLineNum
private

Definition at line 145 of file Exception.h.

Referenced by Line(), LogException(), Print(), and ToString().

◆ mMessage

std::string trUtil::Exception::mMessage
private

Definition at line 144 of file Exception.h.

Referenced by LogException(), Print(), ToString(), and What().


The documentation for this class was generated from the following files: