Compute Library
 22.08
TestError Class Reference

Error class for failures during test execution. More...

#include <Exceptions.h>

Collaboration diagram for TestError:
[legend]

Public Member Functions

 TestError (const std::string &msg, LogLevel level, std::string context="")
 Construct error with severity. More...
 
LogLevel level () const
 Severity of the error. More...
 
const char * what () const noexcept override
 Get the error message. More...
 

Detailed Description

Error class for failures during test execution.

Definition at line 78 of file Exceptions.h.

Constructor & Destructor Documentation

◆ TestError()

TestError ( const std::string &  msg,
LogLevel  level,
std::string  context = "" 
)

Construct error with severity.

Parameters
[in]msgError message.
[in]levelSeverity level.
[in]contextContext.

Definition at line 112 of file Exceptions.cpp.

References TestError::level().

113  : std::runtime_error{ msg }, _level{ level }, _msg{ msg }, _context{ std::move(context) }, _combined{ "ERROR: " + msg }
114 {
115  if(!_context.empty())
116  {
117  _combined += "\nCONTEXT:\n" + _context;
118  }
119 }
LogLevel level() const
Severity of the error.
Definition: Exceptions.cpp:121

Member Function Documentation

◆ level()

LogLevel level ( ) const

Severity of the error.

Returns
Severity.

Definition at line 121 of file Exceptions.cpp.

Referenced by Framework::error_on_missing_assets(), Framework::log_failed_expectation(), and TestError::TestError().

122 {
123  return _level;
124 }

◆ what()

const char * what ( ) const
overridenoexcept

Get the error message.

Returns
error message.

Definition at line 126 of file Exceptions.cpp.

127 {
128  return _combined.c_str();
129 }

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