Taskolib  1.3.3
Public Member Functions | Private Attributes | Friends | List of all members
task::Error Class Reference

Detailed Description

An exception class carrying an error message and, optionally, the index of the step in which the error occurred.

Error is used as the standard exception class by many functions throughout Taskolib. It can be used directly or inherited from.

try
{
throw task::Error("An error has occurred");
}
catch (const task::Error& e)
{
std::cerr << e.what() << "\n";
}
try
{
throw task::Error("An error has occurred", 42);
}
catch (const task::Error& e)
{
std::cerr << e.what();
auto maybe_step_index = e.get_index();
if (maybe_step_index)
std::cerr << ": step index " << *maybe_step_index;
std::cerr << "\n";
}
An exception class carrying an error message and, optionally, the index of the step in which the erro...
Definition: exceptions.h:73
OptionalStepIndex get_index() const
Return the associated step index.
Definition: exceptions.h:86
Note
task::Error is derived from std::runtime_error. It can therefore be caught by catch (const std::exception&), catch (const std::runtime_error&), and catch (const task::Error&).

#include <exceptions.h>

Inheritance diagram for task::Error:
Inheritance graph

Public Member Functions

 Error (const std::string &msg, OptionalStepIndex opt_step_index=gul14::nullopt)
 
 Error (const char *msg, OptionalStepIndex opt_step_index=gul14::nullopt)
 
OptionalStepIndex get_index () const
 Return the associated step index. More...
 

Private Attributes

OptionalStepIndex index_
 

Friends

bool operator== (const Error &lhs, const Error &rhs) noexcept
 Determine if two Error objects have the same content. More...
 
bool operator!= (const Error &lhs, const Error &rhs) noexcept
 Determine if two Error objects have different content. More...
 

Constructor & Destructor Documentation

◆ Error() [1/2]

task::Error::Error ( const std::string &  msg,
OptionalStepIndex  opt_step_index = gul14::nullopt 
)
inlineexplicit

◆ Error() [2/2]

task::Error::Error ( const char *  msg,
OptionalStepIndex  opt_step_index = gul14::nullopt 
)
inlineexplicit

Member Function Documentation

◆ get_index()

OptionalStepIndex task::Error::get_index ( ) const
inline

Return the associated step index.

References index_.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const Error lhs,
const Error rhs 
)
friend

Determine if two Error objects have different content.

◆ operator==

bool operator== ( const Error lhs,
const Error rhs 
)
friend

Determine if two Error objects have the same content.

Member Data Documentation

◆ index_

OptionalStepIndex task::Error::index_
private

Referenced by get_index().


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