AudioDataLib
A C++ library of classes supporting a variety of audio-data tasks.
Loading...
Searching...
No Matches
AudioDataLib::Error Class Reference

This is class is used throughout the library to communicate errors that can occur during the performance of various operations. More...

#include <Error.h>

Public Member Functions

 Error ()
 
virtual ~Error ()
 
void Add (const std::string &error)
 
std::string GetErrorMessage () const
 
 operator bool () const
 
void Clear ()
 

Protected Attributes

std::vector< std::string > * errorArray
 

Detailed Description

This is class is used throughout the library to communicate errors that can occur during the performance of various operations.

I'm not a fan of exception-throwing, which some may consider a more modern approach. It is a bit combersome to pass an Error class reference all over the place, but it's a convention that I've found works reasonably well, and makes me feel better about the software cleaning up after itself whether an error occurs or not. One advantage to not throwing exceptions is that the caller doesn't have to try (and often fail) to catch exceptions (due to not knowing which to catch or just not trying). Rather, the caller just needs to be in the habit of always checking the return value. They can choose to ignore the return value, but it's always there for them to be able to check if they want.

Constructor & Destructor Documentation

◆ Error()

Error::Error ( )

◆ ~Error()

Error::~Error ( )
virtual

Member Function Documentation

◆ Add()

void Error::Add ( const std::string & error)

Append an error message to the list of errors maintained by this object.

◆ Clear()

void Error::Clear ( )

Clear the maintained error list so that it's empty.

◆ GetErrorMessage()

std::string Error::GetErrorMessage ( ) const

Return a single string formatted with all errors in the maintained error list.

◆ operator bool()

Error::operator bool ( ) const

Return true if one or more errors have been added to the maintained error list.

Member Data Documentation

◆ errorArray

std::vector<std::string>* AudioDataLib::Error::errorArray
protected

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