You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
733 B
C++

/**
* @file error.cpp
* @brief Tracks and reports non-critical errors.
*
* Copyright (C) 2021 Clyne Sullivan
*
* Distributed under the GNU GPL v3 or later. You should have received a copy of
* the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
*/
#include "error.hpp"
ErrorManager EM;
void ErrorManager::add(Error error)
{
if (m_index < m_queue.size())
m_queue[m_index++] = error;
}
bool ErrorManager::assert(bool condition, Error error)
{
if (!condition)
add(error);
return condition;
}
bool ErrorManager::hasError()
{
return m_index > 0;
}
Error ErrorManager::pop()
{
return m_index == 0 ? Error::None : m_queue[--m_index];
}